function(arg..., options)
Parameters
-
arg
{*}
Optional Variable
Arguments passed from the tag. After the helper
name, any space seperated keys, numbers or
strings are passed as arguments.
The following template:
<p>{{madLib "Lebron James" verb 4}}</p>
Rendered with
{verb: "swept"}
Will call a madLib
helper with the following arguements.
can.mustache.registerSimpleHelper('madLib',
function(subject, verb, number){
// subject -> "Lebron James"
// verb -> "swept"
// number -> 4
});
Unlike can.mustache.helper simple helpers will always pass the actual
value (instead of a compute).
-
An options object
that gets populated with optional:
fn
and inverse
section rendering functions
- a
hash
object of the maps passed to the helper
Returns
{String | function(HTMLElement)}
The content to be inserted into
the template.
This
The context the helper was
called within.
can.mustache.simpleHelper
Returning an element callback function
If a helper returns a function, that function is called back after the template has been rendered into DOM elements. This can be used to create mustache tags that have rich behavior.
If the helper is called within a tag like:
The returned function is called with the
<ul>
element:If the helper is called between tags like:
The returned function is called with a temporary element. The following helper would be called with a temporary
<li>
element:The temporary element depends on the parent element. The default temporary element is a
<span>
element.