forked from BorisMoore/jquery-tmpl
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added support for elseif semantics, and a new comment tag.
For if, else if, else use: {{if a}}...{{else b}}...{{else}}...{{/if}} For comments within templates, use {{! Here is my comment }}. Added a new sample: samplesCore/condition.html, to illustrate use of these template tags.
- Loading branch information
1 parent
19f6ba3
commit 7769e2b
Showing
2 changed files
with
54 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
<!-- | ||
This sample illustrates use of conditional template tags {{if}} and {{else}}. | ||
The comment tag {{! }} is also shown. | ||
--> | ||
|
||
<script src="http://code.jquery.com/jquery.js"></script> | ||
<script src="../../jquery.tmpl.js" type="text/javascript"></script> | ||
<script> | ||
$(function(){ | ||
$( "#movieTemplate" ) | ||
.tmpl( movies ) | ||
.appendTo( "#movieList" ); | ||
}); | ||
|
||
var movies = [ | ||
{ Name: "Meet Joe Black", Languages: "French", Subtitles: "English" }, | ||
{ Name: "The Mighty", Subtitles: "French and Spanish" }, | ||
{ Name: "The Mighty" }, | ||
{ Name: "City Hunter", Languages: "Mandarin and Cantonese" } | ||
]; | ||
</script> | ||
|
||
<script id="movieTemplate" type="text/x-jquery-tmpl"> | ||
<li>${Name} | ||
|
||
{{if Languages}} | ||
|
||
(Alternative languages: ${Languages}). | ||
|
||
{{else Subtitles}} {{! Note that the 'else' tag with a parameter behaves as 'else if' }} | ||
|
||
(Original language only. Subtitles in ${Subtitles}). | ||
|
||
{{else}} {{! The 'else' tag with no parameter behaves as 'else' }} | ||
|
||
(Original version only, without subtitles). | ||
|
||
{{/if}} | ||
|
||
</li> | ||
</script> | ||
|
||
<ul id="movieList"></ul> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters