diff options
Diffstat (limited to 'demo/demo.html')
-rw-r--r-- | demo/demo.html | 25 |
1 files changed, 15 insertions, 10 deletions
diff --git a/demo/demo.html b/demo/demo.html index 603a7ac..03b3760 100644 --- a/demo/demo.html +++ b/demo/demo.html @@ -23,27 +23,32 @@ <!-- 模板 --> <script class="show" id="source" type="text/x-handlebars-template"> -{{{link "See more..." story.url}}} +{{#nimo}} +{{.}} {{root.a.b.c}} +{{/nimo}} </script> <!-- 数据 --> <script class="show json-format-error" id="data" type="text/json"> { - "story": { - "url": "http://www.handlebarsjs.org" - } + "a":{ + "b":{ + "c":"cccc" + } + }, + "nimo": [ + 1 + , + 2 + ] } </script> <!-- helper实现 --> <script class="show" id="helper"> -Handlebars.registerHelper('link', function(text, url) { - url = Handlebars.escapeExpression(url); - text = Handlebars.escapeExpression(text); +Handlebars.registerHelper('helper-name', function(obj) { + return 'output' - return new Handlebars.SafeString( - "<a href='" + url + "'>" + text + "</a>" - ); }); </script> <!-- 渲染结果字符 --> |