| Template code | Chunk output | |
|---|---|---|
{#example_1}
{!--
-- {% tagStack %} and {% tagStack(html) %} are useful debug
-- constructs for when you're developing a template and you've
-- forgotten the name of that darn tag where you stashed your data.
--
-- A complete report of all defined tag names right up
-- the stack (yes, you'll have a call stack of tags
-- if you've nested your chunks, or if you're inside a
-- loop or exec body) will be placed into your template
-- output.
--
-- This is a debug tool, so make sure to remove all {% tagStack %}
-- tags from your production environment templates.
--
-- Tag values are not shown in the output, just tag names.
--}
{% loop in $accounts as $acct %}
<div>
{% tagStack(html) %} </div>
<pre>
{% tagStack %} </pre>
{% endloop %}
<h2>JSON data for this example:</h2>
<pre>
{% include #json_accounts_data %}
</pre>
{#}
import net.minidev.json.JSONValue;
//...
Theme theme = new Theme("examples");
// fetch template snippet from themes/examples/include.chtml
Chunk html = theme.makeChunk("include#example_1");
Object accts = JSONValue.parse( theme.fetch("include#json_accounts_data") );
html.set("accounts", accts);
StreamWriter out = getStreamWriter();
html.render( out );
|
|
<div>
Available tags:<br/>
$acct<br/>
$accounts<br/>
$now<br/>
</div>
<pre>
Available tags:
$acct
$accounts
$now
</pre>
<div>
Available tags:<br/>
$acct<br/>
$accounts<br/>
$now<br/>
</div>
<pre>
Available tags:
$acct
$accounts
$now
</pre>
<div>
Available tags:<br/>
$acct<br/>
$accounts<br/>
$now<br/>
</div>
<pre>
Available tags:
$acct
$accounts
$now
</pre>
<h2>JSON data for this example:</h2>
<pre>
[ { name: "Bob", account_no: "2312323" },
{ name: "Jim", account_no: "4324323" },
{ name: "Jenny", account_no: "9879879",
swiss_account_no: "3X43J3423A1" }
]
</pre>
Available tags:
$acct $accounts $now
Available tags:
$acct
$accounts
$now
Available tags:
$acct $accounts $now
Available tags:
$acct
$accounts
$now
Available tags:
$acct $accounts $now
Available tags:
$acct
$accounts
$now
JSON data for this example:
[ { name: "Bob", account_no: "2312323" },
{ name: "Jim", account_no: "4324323" },
{ name: "Jenny", account_no: "9879879",
swiss_account_no: "3X43J3423A1" }
]
|