can
Version:
MIT-licensed, client-side, JavaScript framework that makes building rich web applications easy.
82 lines (47 loc) • 2.42 kB
Markdown
fn:can.mustache.sectionRenderer,inverse:can.mustache.sectionRenderer,hash:Object}} can.mustache.helperOptions helperOptions
can.mustache.types
The options argument passed to a [can.mustache.helper helper function].
{can.mustache.sectionRenderer} [fn] Provided if a
[can.mustache.helpers.sectionHelper section helper] is called. Call `fn` to
render the BLOCK with the specified `context`.
{can.mustache.sectionRenderer} [inverse] Provided if a
[can.mustache.helpers.sectionHelper section helper] is called
with [can.mustache.helpers.else {{else}}]. Call `inverse` to
render the INVERSE with the specified `context`.
{Object.<String,*|String|Number>} hash An object containing all of the final
arguments listed as `name=value` pairs for the helper.
{{helper arg1 arg2 name=value other=3 position="top"}}
options.hash = {
name: <context_lookup>.value,
other: 3,
position: "top"
}
{*} context The current context the mustache helper is called within.
var temp = can.mustache(
"{{#person.name}}{{helper}}{{/person.name}}");
var data = {person: {name: {first: "Justin"}}};
can.mustache.registerHelper("helper", function(options){
options.context === data.person //-> true
})
temp(data);
{can.view.Scope} scope An object that represents the current context and all parent
contexts. It can be used to look up [can.mustache.key key] values in the current scope.
var temp = can.mustache(
"{{#person.name}}{{helper}}{{/person.name}}");
var data = {person: {name: {first: "Justin"}}};
can.mustache.registerHelper("helper", function(options){
options.scope.attr("first") //-> "Justin"
options.scope.attr("person") //-> data.person
})
temp(data);
{can.view.Options} options An object that represents the local mustache helpers. It can be used to look
up [can.mustache.key key] values
var temp = can.mustache(
"{{#person.name}}{{helper}}{{/person.name}}");
var data = {person: {name: {first: "Justin"}}};
can.mustache.registerHelper("helper", function(options){
options.options.attr("helpers.specialHelper") //-> function(){ ... }
})
temp(data, {
specialHelper: function(){ ... }
});
{{