zoukankan      html  css  js  c++  java
  • JsRender系列demo(6)-无名

    <!DOCTYPE html>
    <html>
    <head>
    	<script src="http://code.jquery.com/jquery.js" type="text/javascript"></script>
    	<script src="../../jsrender.js" type="text/javascript"></script>
    	<link href="../resources/demos.css" rel="stylesheet" type="text/css" />
    
    	<link href="../resources/movielist.css" rel="stylesheet" type="text/css" />
    </head>
    <body>
    <a href="../demos.html">JsRender Demos</a><br />
    
    <h3>Template composition. Using external templates for block tags, such as {{for}} and {{if}}.</h3>
    
    <script id="movieTemplate" type="text/x-jsrender">
    	<tr>
    		<td>{{include tmpl="#headerTemplate"/}}</td>
    		<td>
    			{{for languages tmpl="#columnTemplate"/}}
    		</td>
    		<td>
    			{{for languages tmpl=tmpl/}}
    		</td>
    		<td>
    			{{for languages tmpl='#conditionalTemplate'/}}
    		</td>
    		{{include tmpl="#sectionWrapperTemplate"}}
    			{{>title}}
    		{{/include}}
    		<td>
    			{{for languages tmpl='#indexWrapperTemplate'}}
    				<b>{{>name}}</b>
    			{{/for}}
    		</td>
    	</tr>
    </script>
    
    <script id="headerTemplate" type="text/x-jsrender">
    	<td>{{>title}}</td>
    </script>
    
    <script id="sectionWrapperTemplate" type="text/x-jsrender">
    	<td>Section: <em>{{include tmpl=#content/}}</em></td>
    </script>
    
    <script id="columnTemplate" type="text/x-jsrender">
    	<div>
    		<em>{{>name}}</em>
    	</div>
    </script>
    
    <script id="rowTemplate" type="text/x-jsrender">
    	<span>
    		<b>{{>name}}</b>
    	</span>
    </script>
    
    <script id="conditionalTemplate" type="text/x-jsrender">
    	{{if name.charAt(0)==='E' tmpl='#rowTemplate'}}
    	{{else tmpl='#columnTemplate'}}
    	{{/if}}
    </script>
    
    <script id="indexWrapperTemplate" type="text/x-jsrender">
    	<div>
    		{{:#index}}:
    		{{include tmpl=#content/}}
    	</div>
    </script>
    
    <table>
    	<thead><tr><th>Synopsis</th><th>Fixed Template</th><th>Template specified in data</th><th>Conditional Template</th><th>Wrapper Template</th><th>Repeating Wrapper Template</th></tr></thead>
    	<tbody id="movieList"></tbody>
    </table>
    
    <script type="text/javascript">
    
    	var movies = [
    		{
    			title: "Meet Joe Black",
    			languages: [
    				{ name: "English" },
    				{ name: "French" }
    			],
    			tmpl: "#columnTemplate"
    		},
    		{
    			title: "Eyes Wide Shut",
    			languages: [
    				{ name: "French" },
    				{ name: "Esperanto" },
    				{ name: "Spanish" }
    			],
    			tmpl: "#rowTemplate"
    		},
    		{
    			title: "The Inheritance",
    			languages: [
    				{ name: "English" },
    				{ name: "German" }
    			],
    			tmpl: "#columnTemplate"
    		}
    	];
    
    	$( "#movieList" ).html(
    		$( "#movieTemplate" ).render( movies )
    	);
    
    </script>
    
    </body>
    </html>
    

      

  • 相关阅读:
    DFS(深度优先搜索)
    dp动态规划 之 背包问题
    python选择排序的实现
    python冒泡排序实现
    python 数据类型
    SyntaxError: Missing parentheses in call to 'print'
    MFC位图传送错误之一
    SyntaxError :invalid syntax
    Python之命令行参数
    Python之print
  • 原文地址:https://www.cnblogs.com/alphafly/p/3872068.html
Copyright © 2011-2022 走看看