-
Notifications
You must be signed in to change notification settings - Fork 2
HelperMethods
- summary Haml Helper Methods.
PHamlP provides some helper methods to make it easier to do various tasks.
The HamlHelpers class can be extended to provide user defined helper methods. The signature for user defined helper methods is ($block, $other, $arguments); $block is the string generated by the Haml block being operated on.
The path to the extended class is provided to HamlParser in the config array; class name == file name.
HamlHelpers and any extended class are automatically included in the context that a Haml template is parsed in, so all the methods are at your disposal from within the template.
Helpers are used within a template like a function and act on a block of Haml code (html_attr() is the exception). e.g.
produces
- append($string)*
- escape_once()*
- html_attrs($language = 'en-us', $lang = true)*
produces
produces
produces
Although handled in HamlParser, the notes below are here for completeness.
Other attributes are defined as normal. e.g.
produces
PHamlP also allows for the language to be defined using PHP code that can be eval'd; the code must end with a semi-colon (;). e.g.
produces (assuming FW::app()->language returns 'en-gb')
- html_escape()*
- list_of($block, $items, $key, $value = null)*
Produces:
And
Produces:
- preceed($string)*
- prepend($string)*
- preserve()*
- succeed($string)*
- surround($front, $back=null)*