20120518 advanced jsrendertemplatingfeatures
TRANSCRIPT
![Page 1: 20120518 advanced jsrendertemplatingfeatures](https://reader035.vdocuments.net/reader035/viewer/2022070317/5564aed2d8b42a3e618b470c/html5/thumbnails/1.jpg)
Advanced JsRender Templating Features
drake
2012/05/181
![Page 2: 20120518 advanced jsrendertemplatingfeatures](https://reader035.vdocuments.net/reader035/viewer/2022070317/5564aed2d8b42a3e618b470c/html5/thumbnails/2.jpg)
Agenda External Templates View Paths Expressions Registering Custom Tags Converters Helper Functions and Template Parameters Helper Functions for Unique Scenarios Which to Use? Allow code
2012/05/182
![Page 3: 20120518 advanced jsrendertemplatingfeatures](https://reader035.vdocuments.net/reader035/viewer/2022070317/5564aed2d8b42a3e618b470c/html5/thumbnails/3.jpg)
External Templates Code reuse is one of the big advantages of using
templates Templates that should accessible from multiple
pages It’s easy to use
2012/05/183
![Page 4: 20120518 advanced jsrendertemplatingfeatures](https://reader035.vdocuments.net/reader035/viewer/2022070317/5564aed2d8b42a3e618b470c/html5/thumbnails/4.jpg)
Suggest Convention External templates is to prefix the file name with an
underscore Suffix all template files with .tmpl.html
2012/05/184
![Page 5: 20120518 advanced jsrendertemplatingfeatures](https://reader035.vdocuments.net/reader035/viewer/2022070317/5564aed2d8b42a3e618b470c/html5/thumbnails/5.jpg)
Code for Rendering an External Template
2012/05/185
![Page 6: 20120518 advanced jsrendertemplatingfeatures](https://reader035.vdocuments.net/reader035/viewer/2022070317/5564aed2d8b42a3e618b470c/html5/thumbnails/6.jpg)
Example
2012/05/186
![Page 7: 20120518 advanced jsrendertemplatingfeatures](https://reader035.vdocuments.net/reader035/viewer/2022070317/5564aed2d8b42a3e618b470c/html5/thumbnails/7.jpg)
View Paths
2012/05/187
![Page 8: 20120518 advanced jsrendertemplatingfeatures](https://reader035.vdocuments.net/reader035/viewer/2022070317/5564aed2d8b42a3e618b470c/html5/thumbnails/8.jpg)
Example
2012/05/188
![Page 9: 20120518 advanced jsrendertemplatingfeatures](https://reader035.vdocuments.net/reader035/viewer/2022070317/5564aed2d8b42a3e618b470c/html5/thumbnails/9.jpg)
Expressions
2012/05/189
![Page 10: 20120518 advanced jsrendertemplatingfeatures](https://reader035.vdocuments.net/reader035/viewer/2022070317/5564aed2d8b42a3e618b470c/html5/thumbnails/10.jpg)
Registering Custom Tags JsRender offers several powerful extensibility points
such as A.A. custom tagscustom tags
B.B. convertersconverters
C.C. helper functions and template parametershelper functions and template parameters The syntax for calling each of these is shown here
A. {{myTag name}}
B. {{myConverter:name}}
C. {{:~myHelper(name)}}{{:~myParameter}}
2012/05/1810
![Page 11: 20120518 advanced jsrendertemplatingfeatures](https://reader035.vdocuments.net/reader035/viewer/2022070317/5564aed2d8b42a3e618b470c/html5/thumbnails/11.jpg)
Custom tags
2012/05/1811
![Page 12: 20120518 advanced jsrendertemplatingfeatures](https://reader035.vdocuments.net/reader035/viewer/2022070317/5564aed2d8b42a3e618b470c/html5/thumbnails/12.jpg)
Converters
2012/05/1812
![Page 13: 20120518 advanced jsrendertemplatingfeatures](https://reader035.vdocuments.net/reader035/viewer/2022070317/5564aed2d8b42a3e618b470c/html5/thumbnails/13.jpg)
Helper Functions and Template Parameters
2012/05/1813
![Page 14: 20120518 advanced jsrendertemplatingfeatures](https://reader035.vdocuments.net/reader035/viewer/2022070317/5564aed2d8b42a3e618b470c/html5/thumbnails/14.jpg)
Helper Functions for Unique Scenarios
2012/05/1814
![Page 15: 20120518 advanced jsrendertemplatingfeatures](https://reader035.vdocuments.net/reader035/viewer/2022070317/5564aed2d8b42a3e618b470c/html5/thumbnails/15.jpg)
Which to Use?
2012/05/1815
![Page 16: 20120518 advanced jsrendertemplatingfeatures](https://reader035.vdocuments.net/reader035/viewer/2022070317/5564aed2d8b42a3e618b470c/html5/thumbnails/16.jpg)
Allow code wrapping the code with a block prefixed with an
asterisk {{* }} setting allowCode to true
2012/05/1816
![Page 17: 20120518 advanced jsrendertemplatingfeatures](https://reader035.vdocuments.net/reader035/viewer/2022070317/5564aed2d8b42a3e618b470c/html5/thumbnails/17.jpg)
Other solution
2012/05/1817
![Page 18: 20120518 advanced jsrendertemplatingfeatures](https://reader035.vdocuments.net/reader035/viewer/2022070317/5564aed2d8b42a3e618b470c/html5/thumbnails/18.jpg)
Reference http://msdn.microsoft.com/en-us/magazine/hh97537
9.aspx
2012/05/1818