You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Jan 26, 2019. It is now read-only.
I'm currently experimenting with the following features.
Sub-templating
Syntax :
<divclass="site-body"><divclass="site-center"><divclass="cell">
{{{template panel this name}}}
</div></div></div>
Explanation :
It includes a template called panel at this very spot
It passes the data for {{this}} and {{name}} to the template
Passing data to helpers
The problem with the syntax {{{template panel this name}}} is that it's rather restrictive in naming of parameters that are past to a subtemplate (or other helper).
To allow more custom naming, alternate syntaxes could be :
The problem with these syntaxes, is distinguishing between what content should passed literally (eg. John) and what content should passed as a reference (eg. this). Variations on this syntax that add this distinction would be :
{{{template panel data=this&name="John"}}}
{{{template panel data=this&name='John'}}}
{{{template panel data={{this}}&name=John}}}
{{{template panel data=$this&name=John}}}
{{{template panel data=${this}&name=John}}}
As any content in between a beginning and end tag remains unparsed for custom helpers, there are nevertheless still many alternatives worth considering :
{{#template panel}}
<inputtype="array" name="data" value="{{this}}" />
<inputtype="string" name="name" value="John" />
<outputtype="string" name="panel" />
<!-- This syntax would even allow you to store the output --><!-- of the template as a variable named panel -->
{{/template}}
{{#template panel}}
data : (array) {{this}}
name : (string) John
{{/template}}
{{#template panel}}
data = {{this}}
name = John
{{/template}}
Would you be interested in adding any of these syntaxes to the XaminProject/handlebars.php library? I am still considering which syntax to use for my own PowerTools project and I figured I might as well contribute the syntax I eventually choose to the XaminProject/handlebars.php project if anyone is interested.
@jslegers, the syntax, you proposed, is not compatible with Handlebars.js. I think there is no reason to implement a new complex arguments passing syntax. It is a step away from compatibility between PHP and JS versions of Handlebars.
I'm currently experimenting with the following features.
Sub-templating
Syntax :
Explanation :
panel
at this very spot{{this}}
and{{name}}
to the templatePassing data to helpers
The problem with the syntax
{{{template panel this name}}}
is that it's rather restrictive in naming of parameters that are past to a subtemplate (or other helper).To allow more custom naming, alternate syntaxes could be :
See also #44
The problem with these syntaxes, is distinguishing between what content should passed literally (eg.
John
) and what content should passed as a reference (eg.this
). Variations on this syntax that add this distinction would be :As any content in between a beginning and end tag remains unparsed for custom helpers, there are nevertheless still many alternatives worth considering :
Would you be interested in adding any of these syntaxes to the
XaminProject/handlebars.php
library? I am still considering which syntax to use for my ownPowerTools
project and I figured I might as well contribute the syntax I eventually choose to theXaminProject/handlebars.php
project if anyone is interested.EDIT :
See also handlebars-lang/handlebars.js#817
The text was updated successfully, but these errors were encountered: