Skip to content

Commit

Permalink
Add script tag support for enclosing a template (ampproject#19346)
Browse files Browse the repository at this point in the history
* merge

* add todo for nested script templates

* fix test

* address jridgewell comments

* lint

* address comments

* fix merge

* fix example

* lint

* address choumx comments

* address choumx comments

* address choumx comments
  • Loading branch information
alabiaga authored and Noran Azmy committed Mar 22, 2019
1 parent c908572 commit b410e91
Show file tree
Hide file tree
Showing 9 changed files with 1,138 additions and 818 deletions.
18 changes: 18 additions & 0 deletions examples/amp-list.amp.html
Expand Up @@ -57,6 +57,24 @@
</template>
</amp-list>

<!-- ## Using a script to enclose the template. -->
<amp-list width="auto" height="100" layout="fixed-height" src="comments.example.json">
<script type="text/plain" template="amp-mustache">
<table>
<tr>
<td>Comment:</td>
<td>{{content}}</td>
</tr>
{{#replies}}
<tr>
<td>Reply:</td>
<td>{{content}}</td>
</tr>
{{/replies}}
</table>
</script>
</amp-list>

<!-- ## Using an existing template -->
<!--
The template can also be specified using an ID of an existing
Expand Down
6 changes: 6 additions & 0 deletions examples/comments.example.json
@@ -0,0 +1,6 @@
{
"items": [
{"content": "Hello", "replies": [{"content": "Hi"}]},
{"content": "Howdy", "replies": []}
]
}

0 comments on commit b410e91

Please sign in to comment.