Sha256: 2856a1a345752c795dcb794fdad1bb89d81764d86289f53fc47b2fc88b56fed0

Contents?: true

Size: 1.89 KB

Versions: 15

Compression:

Stored size: 1.89 KB

Contents

<!DOCTYPE html>
<html>
<head>
	<link href="resources/presentation.css" rel="stylesheet" type="text/css" />
	<link href="resources/syntaxhighlighter.css" rel="stylesheet" type="text/css" />
	<script src="resources/syntaxhighlighter.min.js" type="text/javascript"></script>

	<script src="http://code.jquery.com/jquery.js" type="text/javascript"></script>
	<script src="../../jsrender.js" type="text/javascript"></script>
</head>
<body>
<a href="09_for-composition.html">Prev</a> <a href="index.html">Home</a> <a href="11_editable-data.html">Next</a><br />

<h3>13 Using {{if}} and {{else}} to render conditional sections</h3>

<script id="movieTemplate" type="text/x-jsrender">
	<tr>
		<td>{{:title}}</td>
		<td>
			{{if languages}}
				Alternative languages: <em>{{:languages}}</em>.
			{{else subtitles}}
				Subtitles in <em>{{:subtitles}}</em>.
			{{else}}
				Original version only, without subtitles.
			{{/if}}
		</td>
	</tr>
</script>

<table><tbody class="header"><tr><th>Title</th><th>Languages</th></tr></tbody>
	<tbody id="movieList"></tbody>
</table>

<script type="text/javascript">

	var movies = [
		{
			title: "Meet Joe Black",
			languages: "English and French",
			subtitles: "English"
		},
		{
			title: "Eyes Wide Shut",
			subtitles: "French and Spanish"
		},
		{
			title: "The Mighty"
		}
	];

	$( "#movieList" ).html(
		$( "#movieTemplate" ).render( movies )
	);

</script>

<!--================ End of Demo Section ================-->

<h4>HTML:</h4>
<pre class="brush: xml;">
&lt;td>
    {{if languages}}
        ...
    {{else subtitles}}
        ....
    {{else}}
        ...
    {{/if}}
&lt;/td>
</pre>

<h4>Data:</h4>
<pre class="brush: js;">
var movies = [
    {
        title: "Meet Joe Black",
        languages: "English and French",
        subtitles: "English"
    },
    {
        title: "Eyes Wide Shut",
        subtitles: "French and Spanish"
    },
    ...
];
</pre>

</body>
</html>


Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
kit_cms-2.3.22 app/assets/javascripts/views/demos/jQueryConfDemosOct2011/10_if-else-tag.html
kit_cms-2.3.20 app/assets/javascripts/views/demos/jQueryConfDemosOct2011/10_if-else-tag.html
kit_cms-2.3.19 app/assets/javascripts/views/demos/jQueryConfDemosOct2011/10_if-else-tag.html
kit_cms-2.3.18 app/assets/javascripts/views/demos/jQueryConfDemosOct2011/10_if-else-tag.html
kit_cms-2.3.17 app/assets/javascripts/views/demos/jQueryConfDemosOct2011/10_if-else-tag.html
kit_cms-2.3.16 app/assets/javascripts/views/demos/jQueryConfDemosOct2011/10_if-else-tag.html
kit_cms-2.3.15 app/assets/javascripts/views/demos/jQueryConfDemosOct2011/10_if-else-tag.html
kit_cms-2.3.14 app/assets/javascripts/views/demos/jQueryConfDemosOct2011/10_if-else-tag.html
kit_cms-2.3.13 app/assets/javascripts/views/demos/jQueryConfDemosOct2011/10_if-else-tag.html
kit_cms-2.3.11 app/assets/javascripts/views/demos/jQueryConfDemosOct2011/10_if-else-tag.html
kit_cms-2.3.10 app/assets/javascripts/views/demos/jQueryConfDemosOct2011/10_if-else-tag.html
kit_cms-2.3.9 app/assets/javascripts/views/demos/jQueryConfDemosOct2011/10_if-else-tag.html
kit_cms-2.3.8 app/assets/javascripts/views/demos/jQueryConfDemosOct2011/10_if-else-tag.html
kit_cms-2.3.7 app/assets/javascripts/views/demos/jQueryConfDemosOct2011/10_if-else-tag.html
kit_cms-2.3.6 app/assets/javascripts/views/demos/jQueryConfDemosOct2011/10_if-else-tag.html