summaryrefslogtreecommitdiffstats
path: root/posts/execution.md
diff options
context:
space:
mode:
authornimojs <imhadley@163.com>2015-04-19 23:14:19 +0800
committernimojs <imhadley@163.com>2015-04-19 23:14:19 +0800
commitcbaf08642e63b1dc50b99ba5ac41ea1ecc4b7163 (patch)
tree2d2d55cfbd5e9b89a99223d2e30037ed4ba14cae /posts/execution.md
parent720cb5a6ba938cb9864bd24d6df5527b5cdbfa91 (diff)
downloadhandlebarsjs.org-origin/master.zip
handlebarsjs.org-origin/master.tar.gz
handlebarsjs.org-origin/master.tar.bz2
增加章节,静态资源文件目录调整
Diffstat (limited to 'posts/execution.md')
-rw-r--r--posts/execution.md54
1 files changed, 54 insertions, 0 deletions
diff --git a/posts/execution.md b/posts/execution.md
new file mode 100644
index 0000000..fc0ed4d
--- /dev/null
+++ b/posts/execution.md
@@ -0,0 +1,54 @@
+<!--_PAGEDATA
+{
+ "title": "Handlebars 中文网:轻逻辑语义化的模板引擎",
+ "github":"nimojs/handlebarsjs.org",
+ "githubissuesid": 1,
+ "createData": "2015-04-10",
+ "keywords": "",
+ "description": "轻逻辑语义化的模板引擎",
+ "_template": "default"
+}
+_PAGEDATA-->
+
+<!---<div id="intro">-->
+
+传入数据,执行 Handlebars 返回 渲染后的 HTML。
+
+```html
+var source = $("#entry-template").html();
+var template = Handlebars.compile(source);
+
+var context = {title: "My New Post", body: "This is my first post!"}
+var html = template(context);
+```
+渲染结果
+
+```html
+<div class="entry">
+ <h1>My New Post</h1>
+ <div class="body">
+ This is my first post!
+ </div>
+</div>
+```
+
+[示例](demo/execution-1.html)
+
+<!---</div>-->
+
+选项
+-------
+
+这里的 `template()` 允许传入第二个参数作为选项
+
+The template function can be passed an options object as the second parameter which allows for customization:
+
+
+- `data` Pass in an object to define custom `@variable` private variables.
+- `helpers` Pass in to provide custom helpers in addition to the globally defined helpers.
+Values defined in this object will replace any values defined in the global object for the duration of the template execution.
+- `partials` Pass in to provide custom partials in addition to the globally defined partials.
+Values defined in this object will replace any values defined in the global object for the duration of the template execution.
+
+
+<!-- End .contents--> \ No newline at end of file