Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

adding example with nested paths

  • Loading branch information...
commit 2b3ced088d963c18d713ab147cb61eedc36c8b69 1 parent 7f686a8
@addyosmani authored
Showing with 26 additions and 2 deletions.
  1. +26 −2 README.md
View
28 README.md
@@ -2,7 +2,7 @@ A very compact micro-templating solution created for learning purposes. Currentl
### Sample usage
-Example: Populating a separately defined template
+Example: Script-tag based templating
```javascript
<script type="text/micro" id="myTemplate">
@@ -16,7 +16,6 @@ Example: Populating a separately defined template
</script>
<script>
-// alternatively $("#myTemplate").html() works just as well
var markup = document.getElementById("myTemplate").innerHTML,
data = {
username: "addyosmani",
@@ -32,6 +31,31 @@ console.log('Test:' + templatez(markup, data));
</script>
```
+Example: Support for nested paths (ie x.y)
+
+```javascript
+<script id="myTemplate" type="text/micro">
+ <div class='username'> {{username}} </div>
+ <div class="features"> {{features.hair}}, {{features.eyes}}, {{features.height}}</div>
+</script>
+
+<script>
+var markup = $("#myTemplate").html(),
+ data = {
+ username: "addyosmani",
+ features:{
+ hair:'black',
+ eyes: 'brown',
+ height:'5.8'
+ }
+ };
+
+// Log the templated output or populate some an element
+// on the page with it
+console.log('Test:' + templatez(markup, data));
+</script>
+```
+
Example: Basic inline templating
Please sign in to comment.
Something went wrong with that request. Please try again.