diff --git a/docs/template.html b/docs/template.html new file mode 100644 index 0000000000000000000000000000000000000000..581bb46cd20b263daf90ec49a97fb761d6f47d4b --- /dev/null +++ b/docs/template.html @@ -0,0 +1,3 @@ +This is the contents of the file "template.html". + +It is rendered as a template. 1 + 2 = <%- 1 + 2 %>. diff --git a/docs/template.md b/docs/template.md index 35d9c3a44f5e22cddd608c07332c131aa218d7c4..8ccceb6b531ecba18382d10e41622cf824816e85 100644 --- a/docs/template.md +++ b/docs/template.md @@ -20,14 +20,15 @@ This displays `Your platform is ...` and shows the userAgent just below the scri The template can use all global variables. You can pass additional variables using as `.template({var1: value, var2: value, ...})`. For example: + ```html - ``` @@ -45,21 +46,22 @@ for this to work. For example, this shows a circle in SVG bouncing around smoothly. + ```html - - + ``` @@ -77,42 +79,60 @@ To re-use the template or render the same template on a different DOM node, run `.template(data, {target: selector})`. This allows you to declare templates once and apply them across the body. For example: -```js -$('script.chart') - .template({heading: 'Dashboard 1'}, {target: '.dashboard1'}) - .template({heading: 'Dashboard 2'}, {target: '.dashboard2'}) - .template({}, {target: '.no-heading'}) + +```html +
+ + + ``` -The target can also be specified via a `data-target=".dashboard1"` on the script -template. This is the same as specifying `{target: '.dashboard'}`. For example: +The target can also be specified via a `data-target=".panel1"` on the script +template. This is the same as specifying `{target: '.panel'}`. For example: ```html - - + + ``` ## $.template append -To append instead of replacing, run `.template(data, {append: true})`. Every -time `.template` is called, it appends rather than replaces. For example: +To append instead of replacing, use `data-append="true"`. Every time `.template` +is called, it appends rather than replaces. For example: -```js + +```html + + ``` -You can also specify this as ` -