20120518 advanced jsrendertemplatingfeatures

Post on 27-May-2015

402 Views

Category:

Technology

3 Downloads

Preview:

Click to see full reader

TRANSCRIPT

Advanced JsRender Templating Features

drake

2012/05/181

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

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

Suggest Convention External templates is to prefix the file name with an

underscore Suffix all template files with .tmpl.html

2012/05/184

Code for Rendering an External Template

2012/05/185

Example

2012/05/186

View Paths

2012/05/187

Example

2012/05/188

Expressions

2012/05/189

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

Custom tags

2012/05/1811

Converters

2012/05/1812

Helper Functions and Template Parameters

2012/05/1813

Helper Functions for Unique Scenarios

2012/05/1814

Which to Use?

2012/05/1815

Allow code wrapping the code with a block prefixed with an

asterisk {{* }}  setting allowCode to true

2012/05/1816

Other solution

2012/05/1817

Reference http://msdn.microsoft.com/en-us/magazine/hh97537

9.aspx

2012/05/1818

top related