zoukankan      html  css  js  c++  java
  • JTemplate学习(三)

    另一种模板写法

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
    <!-- saved from url=(0043)http://jtemplates.tpython.com/example3.html -->
    <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
        <script type="text/javascript" src="Scripts/jTemplates/example/jquery.js"></script>
        <script type="text/javascript" src="Scripts/jTemplates/jquery-jtemplates.js"></script>
        <title>jTemplates</title>
    
        <script type="text/javascript">
            // data for testing
            $(document).ready(function () {
                var data = {
                    name: 'User list',
                    list_id: 4,
                    table: [
    					{ id: 1, name: 'Anne', age: 22, mail: 'anne@domain.com' },
    					{ id: 2, name: 'Amelie', age: 24, mail: 'amelie@domain.com' },
    					{ id: 3, name: 'Polly', age: 18, mail: 'polly@domain.com' },
    					{ id: 4, name: 'Alice', age: 26, mail: 'alice@domain.com' },
    					{ id: 5, name: 'Martha', age: 25, mail: 'martha@domain.com' }
                    ]
                };
    
                // attach the template
                $("#result1").setTemplateElement("template");
    
                // process the template
                $("#result1").processTemplate(data);
            });
        </script>
    
        <style type="text/css">
            .jTemplatesTest {
                background: #DDD;
                border: 1px solid #000;
                margin: 2em;
                 480px;
            }
    
                .jTemplatesTest * {
                    padding: 4px;
                    margin: 2px auto;
                }
    
                .jTemplatesTest td, tr {
                    background: #EEE;
                    border: 1px solid black;
                }
        </style>
    
    </head>
    
    <body style="zoom: 1;">
    
        <!-- Template content (Valid XHTML 1.1) -->
        <p style="display: none">
            <textarea id="template" rows="0" cols="0">
                <!--
    		<strong>{$T.name}: {$T.list_id}</strong>
    		<table>
    			{#foreach $T.table as record}
    			<tr>
    					<td>{$T.record.name}</td>
    					<td>{$T.record.mail}</td>
    			</tr>
    			{#/for}
    		</table>
    	--></textarea>
        </p>
    
        <!-- Output elements -->
        <div id="result1" class="jTemplatesTest">
        </div>
    </body>
    </html>
    
  • 相关阅读:
    tcpdump抓localhost 127.0.0.1的包
    fatal: write failure on 'stdout': Bad file descriptor
    rst转html
    Call to WHvSetupPartition failed: ERROR_SUCCESS (Last=0xc000000d/87) (VERR_NEM_VM_CREATE_FAILED)
    error: 'readdir_r' is deprecated [-Werror=deprecated-declarations]
    ubuntu虚拟机设置共享后无权限
    VirtualBox怎么设置从u盘启动,虚拟机从U盘启动
    File类总结
    相对路径的写法
    systeminfo总结
  • 原文地址:https://www.cnblogs.com/xsj1989/p/5191937.html
Copyright © 2011-2022 走看看