-
Notifications
You must be signed in to change notification settings - Fork 17
template
Pierre edited this page Aug 12, 2014
·
1 revision
- Based on the Handlebars.js
- Simple templating language
- A template consume a json object
- Properties are accessed with
{{key}} - A set of helpers is available
- Custom Helpers can be written
<form>
{{input_for "fisrtName"}}
{{input_for "lastName"}}
{{input_for "age"}}
<button type='submit'>Save</button>
</form>
In the fmk, there are custom helpers: they take care of rendering, using metadatas.
- input_for : Deals with inputs
- options_selected : Deals with inputs
- display_for : Read only fields
- hasRole : Deals with roler
- t : Deals with translations.
Example of code for the button:
Handlebars.registerHelper "statusIcon", (property, options)->
if typeof(this[property] == "boolean")
if this[property] then icon = "fa fa-check" else icon = "fa fa-exclamation"
else switch this[property]
when 0 then icon = "fa fa-ban";
when 1 then icon = "fa fa-exclamation";
when 2 then icon = "fa fa-clock-o";
when 3 then icon = "fa fa-check";
else icon = ""
return new Handlebars.SafeString("<i class='#{icon}'><i>");