Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I created a fiddle to show you how use a helper function to return the title. It combines helper functions and view paths using the new beta candidate syntax. I did not need to use allowCode to do this ... allowCode let's you define variables and process logic, but its not full access to the given javascript (for safety). Regardless, I think the code is much cleaner without the allowCode, but you make the call :)</p> <p><a href="http://jsfiddle.net/johnpapa/LqchY/">http://jsfiddle.net/johnpapa/LqchY/</a></p> <p>Note that the new changes from Boris post: <a href="http://www.borismoore.com/2012/03/approaching-beta-whats-changing-in_06.html">http://www.borismoore.com/2012/03/approaching-beta-whats-changing-in_06.html</a></p> <p>The code below has these notable changes:</p> <ol> <li>The new syntax is to use {{:yourProperty}} to render the property value. </li> <li>{{#each}} has been replaced with {{for}}</li> <li>helper functions are now referenced with a tilda ~ instead of ctx</li> <li>When inside of a for loop, you can access the parent context using the #view.parent or simply #parent (because view is implied). So wen inside of an array loop you must 1 parent gets you to the array, another parent gets you to the parent of the array, and data gets you the data. Its a little verbose, but it allows you to have access to context. {{:#parent.parent.data.Title}}</li> <li><strong>[UPDATED]</strong> You can either pass in the data you want to use, or you can access the view.data inside of the function.</li> </ol> <p>I hope this helps!</p> <pre><code>&lt;script id="movieTemplate" type="text/x-jsrender"&gt; &lt;tr&gt; &lt;td&gt;{{:Title}}&lt;/td&gt; &lt;td&gt; &lt;!-- Use the helper function to display the title --&gt; {{:~GetTitleFunction()}} {{for Languages}} &lt;div&gt; &lt;em&gt;{{:Name}}&lt;/em&gt; &lt;!-- Use the view path for parent. could also do #view.parent.parent.data --&gt; &lt;em&gt;( {{:#parent.parent.data.Title}} )&lt;/em&gt; &lt;!-- Use the helper function and view path --&gt; &lt;em&gt;{{:~GetTitleFunction(#parent.parent.data)}}&lt;/em&gt; &lt;/div&gt; {{/for}} &lt;/td&gt; &lt;/tr&gt; &lt;/script&gt; </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload