summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjohneke <john.eke@gmail.com>2015-03-18 20:23:15 -0400
committerjohneke <john.eke@gmail.com>2015-03-18 20:23:15 -0400
commitfed86c01adff202766a6781135178f87ac209d86 (patch)
treeceaeda1b03531eae55c66efadb377adebe518599
parentab96073c6bfde771dde1e8ff1aa7444192f7f6df (diff)
downloadhandlebars.js-fed86c01adff202766a6781135178f87ac209d86.zip
handlebars.js-fed86c01adff202766a6781135178f87ac209d86.tar.gz
handlebars.js-fed86c01adff202766a6781135178f87ac209d86.tar.bz2
Adding documentation for parameters in partials
-rw-r--r--README.markdown25
1 files changed, 25 insertions, 0 deletions
diff --git a/README.markdown b/README.markdown
index a9f25d2..0efc733 100644
--- a/README.markdown
+++ b/README.markdown
@@ -236,6 +236,31 @@ template(data);
// </ul>
```
+Partials can also accept parameters
+
+```js
+var source = "<div>{{> roster people=listOfPeople rosterName}}</div>";
+
+Handlebars.registerPartial('roster', '<h2>{{rosterName}}</h2>{{#people}}<span>{{id}}: {{name}}</span>{{/people}}')
+var template = Handlebars.compile(source);
+
+var data = { "listOfPeople": [
+ { "name": "Alan", "id": 1 },
+ { "name": "Yehuda", "id": 2 }
+ ],
+ "rosterName": "Cool People" };
+
+template(data);
+
+// Should render:
+// <div>
+// <h2>Cool People</h2>
+// <span>1: Alan</span>
+// <span>2: Yehuda</span>
+// </div>
+
+```
+
### Comments
You can add comments to your templates with the following syntax: