| 1 |
<!-- Mustache / Handlebars / Ractive template --> |
| 2 |
<!DOCTYPE html> |
| 3 |
<html> |
| 4 |
<head> |
| 5 |
<meta charset="UTF-8" /> |
| 6 |
<title>{{title}}</title> |
| 7 |
</head> |
| 8 |
<!-- CSS --> |
| 9 |
<style> |
| 10 |
/* Mustache variable support in CSS is incomplete */ |
| 11 |
{{mustache}} |
| 12 |
[ {{other}} ] |
| 13 |
body { |
| 14 |
{{{other}}} |
| 15 |
font-size: 15pt; |
| 16 |
font-family: Verdana; |
| 17 |
} |
| 18 |
</style> |
| 19 |
<!-- JavaScript --> |
| 20 |
<script> |
| 21 |
var foo = {{bar}}; |
| 22 |
`template {{foo}} ${ var a = {{b}} }` |
| 23 |
</script> |
| 24 |
|
| 25 |
<body> |
| 26 |
{{#movie}} |
| 27 |
<div> |
| 28 |
<h1>{{title}}</h1> |
| 29 |
<img src="{{poster}}" alt="{{title}}"/> |
| 30 |
</div> |
| 31 |
<div> |
| 32 |
Rating - {{ratings.critics_rating}} |
| 33 |
</div> |
| 34 |
{{/movie}} |
| 35 |
{{^movie}} |
| 36 |
<div> |
| 37 |
Movie Does Not Exist :( |
| 38 |
</div> |
| 39 |
{{/movie}} |
| 40 |
{{! this is a comment TODO ALERT }} |
| 41 |
|
| 42 |
This is a partial {{> partial1 }} |
| 43 |
{{#block |
| 44 |
param=foo |
| 45 |
param2=bar}} |
| 46 |
{{block foo=bar}} |
| 47 |
{{/block}} |
| 48 |
|
| 49 |
<!-- Handlebars --> |
| 50 |
|
| 51 |
{{#list people}}{{firstName}} {{lastName}}{{/list}} |
| 52 |
{{#noop}}{{body}}{{/noop}} |
| 53 |
{{#with story}} |
| 54 |
<div class="intro">{{{intro}}}</div> |
| 55 |
<div class="body">{{{body}}}</div> |
| 56 |
{{/with}} |
| 57 |
{{#each comments}} |
| 58 |
<div class="comment"> |
| 59 |
<h2>{{subject}}</h2> |
| 60 |
{{{body}}} |
| 61 |
</div> |
| 62 |
{{/each}} |
| 63 |
{{#list nav}} |
| 64 |
<a href="{{url}}">{{title}}</a> |
| 65 |
{{/list}} |
| 66 |
|
| 67 |
{{!-- Conditionals --}} |
| 68 |
{{#if isActive}} |
| 69 |
<img src="star.gif" alt="Active"> |
| 70 |
{{else if isInactive}} |
| 71 |
<img src="cry.gif" alt="Inactive"> |
| 72 |
{{else}} |
| 73 |
<img src="cry.gif" alt=""> |
| 74 |
{{/if}} |
| 75 |
|
| 76 |
{{!-- Escaping --}} |
| 77 |
\{{escaped}} |
| 78 |
{{{{raw}}}} |
| 79 |
{{escaped}} |
| 80 |
{{{{/raw}}}} |
| 81 |
|
| 82 |
{{!-- Whitespace Control --}} |
| 83 |
{{#each nav ~}} |
| 84 |
<a href="{{url}}"> |
| 85 |
{{~#if test}} |
| 86 |
{{~title}} |
| 87 |
{{~^~}} |
| 88 |
Empty |
| 89 |
{{~/if~}} |
| 90 |
</a> |
| 91 |
{{~/each}} |
| 92 |
|
| 93 |
{{!-- Helpers --}} |
| 94 |
{{link "See more..." story.url}} |
| 95 |
{{log "Look at me!" level="error"}} |
| 96 |
|
| 97 |
{{!-- Partial --}} |
| 98 |
{{> myPartial name=../name }} |
| 99 |
{{#> myPartial }} |
| 100 |
Failover content |
| 101 |
{{/myPartial}} |
| 102 |
{{#*inline "myPartial"}} |
| 103 |
My Content |
| 104 |
{{/inline}} |
| 105 |
{{#each children}} |
| 106 |
{{> myPartial}} |
| 107 |
{{/each}} |
| 108 |
|
| 109 |
<!-- Delimiters in tags (folding) --> |
| 110 |
word<div>word |
| 111 |
|
| 112 |
word</div>word |
| 113 |
|
| 114 |
</body> |
| 115 |
</html> |