can.stache.sectionRenderer
{function(context, helpers)}
Renders a section. These functions are usually provided as .fn
and .inverse
on a stache helper's options.
function(context, helpers)
Parameters
-
Specifies the data the section is rendered
with. If a can.view.Scope is provided, that scope is used to render the
section. If anything else is provided, it is used to create a new scope object
with the current scope as it's parent. If nothing is provided, the current
scope is used to render the section.
-
Specifies the helpers the section is rendered
with. If a can.view.Options is provided, that scope is used to render the
section. If anything else is provided, it is used to create a new scope object
with the current helper scope as it's parent. If nothing is provided, the current
helper scope is used to render the section.
Returns
{documentFragment | String}
Returns the rendered result of the helper. If the
section is within a tag, like:
<h1 {{#helper}}class='power'{{/helper}}>
a String is returned.
If the section is outside a tag like:
<div> {{#helper}}<h2>Tasks</h2>{{/helper}} </div>
a documentFragment is returned.
Use
Renderer functions are provided to stache helpers on the options argument and are used to render the content between sections. The
context
andhelpers
option let you control the data and helpers used to render the section.The following example adds
{first: "Justin"}
to the lookup data. Notice how the section has access tofirst
andlast
.If no
context
is provided, the current context is passed. Notice how the section has access tolast
:If a can.view.Scope is provided, it is used to render the section. Notice how
last
is not available in the section: