Sha256: 8226df0e0848da521e19231df0b2a09b5e487f0301cea0dd0c533e8a283b6b19
Contents?: true
Size: 1.99 KB
Versions: 15
Compression:
Stored size: 1.99 KB
Contents
<!DOCTYPE html> <html> <head> <link href="resources/presentation.css" rel="stylesheet" type="text/css" /> <link href="resources/syntaxhighlighter.css" rel="stylesheet" type="text/css" /> <script src="resources/syntaxhighlighter.min.js" type="text/javascript"></script> <script src="http://code.jquery.com/jquery.js" type="text/javascript"></script> <script src="../../jsrender.js" type="text/javascript"></script> </head> <body> <a href="11_editable-data.html">Prev</a> <a href="index.html">Home</a> <a href="13_converters.html">Next</a><br /> <h3>15 Custom helper functions for computed parameters</h3> <script id="movieTmpl" type="text/x-jsrender"> <tr> <td>{{:title}}</td> <td> {{for languages}} {{:name}}{{if ~nextToLast()}} and {{else ~notLast()}}, {{/if}} {{/for}} </td> </tr> </script> <table><tbody class="header"><tr><th>Title</th><th>Languages</th></tr></tbody> <tbody id="movieList"></tbody> </table> <script type="text/javascript"> $.views.helpers({ nextToLast: function() { var view = this; return view.index === view.parent.data.length - 2; }, notLast: function() { var view = this; return view.index !== view.parent.data.length - 1; } }); var movie = { title: "Eyes Wide Shut", languages: [ { name: "French" }, { name: "German" }, { name: "Spanish" } ] }; $( "#movieList" ).html( $( "#movieTmpl" ).render( movie ) ); </script> <!--================ End of Demo Section ================--> <h4>HTML:</h4> <pre class="brush: xml;"> <td> {{for languages}} {{:name}} {{if ~nextToLast()}} and {{else ~notLast()}} , {{/if}} {{/for}} </td> </pre> <h4>Script:</h4> <pre class="brush: js;"> $.views.helpers({ nextToLast: function() { var view = this; return view.index === view.parent.data.length - 2; }, notLast: function() { var view = this; return view.index !== view.parent.data.length - 1; } }); </pre> </body> </html>
Version data entries
15 entries across 15 versions & 1 rubygems