Laravel Community Tools by Tighten

Tag "templating" tricks

57 tricks
Creating a form macro is very easy and awesome for creating your own UI elements. The original downside I found was losing the automatic model binding from Form::model(). A user on StackOverflow helped solve the problem for me.
chadwithuh... 12 years ago 10139
There are a few tips already for active states on navigation, however none are based on Route names. I prefer to use Route names for all routes, so here is a modified version of the "active states" trick for route names.
chadwithuh... 12 years ago 12877
An easy helper method that will assist in setting active classes for navigation items based on the current route.
mattems 12 years ago 27602
Check if the request matches the url. If so, add an active class to the menu item.
xtrasmal 12 years ago 12463
Previously, if you wanted to output a default value of a string in Blade you would put a condition that checks if the variable is set, otherwise defaults to some value. Now you can shorten the code by using the keyword "or" to specify what should be displayed if the variable is not set.
msurguy 12 years ago 11242
A Link assets based on which controller is currently requested. Any improvements to this code are welcome
JonathanFr... 12 years ago 11678
If you find out, that your blade template is empty and no error message generated: double check your comments
mring 12 years ago 8374
This trick is what we use to make writing controllers very quick and easy. The base controller has methods plugged in where needed to automatically load views to a set of templates on it's own. All you need to do is pass it the data you want displayed. It also handles missingmethod to automatically look for logical views. Let me know what you think or any ideas for improving upon it. As a note, I use a separate controller to set the page title and menu items.
stygian 12 years ago 14640
This trick is handy for wrapping all of your form elements with the same HTML/classes, which is especially useful for handling error states when using frameworks like Bootstrap or Foundation.
crhayes 12 years ago 12318