Skip to content

Commit

Permalink
adding example with nested paths
Browse files Browse the repository at this point in the history
  • Loading branch information
addyosmani committed Oct 16, 2011
1 parent 7f686a8 commit 2b3ced0
Showing 1 changed file with 26 additions and 2 deletions.
28 changes: 26 additions & 2 deletions README.md
Expand Up @@ -2,7 +2,7 @@ A very compact micro-templating solution created for learning purposes. Currentl


### Sample usage ### Sample usage


Example: Populating a separately defined template Example: Script-tag based templating


```javascript ```javascript
<script type="text/micro" id="myTemplate"> <script type="text/micro" id="myTemplate">
Expand All @@ -16,7 +16,6 @@ Example: Populating a separately defined template
</script> </script>


<script> <script>
// alternatively $("#myTemplate").html() works just as well
var markup = document.getElementById("myTemplate").innerHTML, var markup = document.getElementById("myTemplate").innerHTML,
data = { data = {
username: "addyosmani", username: "addyosmani",
Expand All @@ -32,6 +31,31 @@ console.log('Test:' + templatez(markup, data));
</script> </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 Example: Basic inline templating


Expand Down

0 comments on commit 2b3ced0

Please sign in to comment.