標籤:style blog http java color 使用 os 資料
<!DOCTYPE html><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><title></title><script type="text/javascript" src="scripts/jquery.js"></script><script type="text/javascript" src="scripts/jquery-ui.js"></script><script type="text/javascript" src="scripts/jsrender.js"></script><link href="scripts/demos.css" rel="stylesheet" /><link href="scripts/movielist.css" rel="stylesheet" /><style type="text/css">.role{font-weight: bold;font-style: italic;background-color: Yellow;}.synopsis{background-color: white;padding: 15px;}.director{font-weight: bold;font-style: italic;color: red;}</style></head><body><!--下面的內容只是說明作用--><h3>用{{: }} or {{> }}用可選和編碼展示資料</h3><ul><li><em>{{:value}}</em> —用於渲染值,包括HTML標記。</li><li><em>{{loc:value lang="..."}}</em> —使用自訂轉換器。</li><li><em>{{html:value}}</em> —將使用內建的HTML編碼器。(更好的安全性,在元素的內容,但輕微的效能成本)。</li><li><em>{{>value}}</em> — 內建的HTML編碼器替代文法.</li><li><em>{{attr:availability}}</em> —使用內建的屬性轉換編碼器。(更好的安全屬性)。</li><li><em>{{url:value lang="..."}}</em> — 使用內建的URL編碼轉換。</li></ul><br /><div class="box label"><b>Note:</b> A common use for converters is to protect against injection attacks from untrusted data.<br />It is generally best to use <b>{{> }}</b> when rendering data within element content, if the data is not intended to provide markup for insertion in the DOM.<br />In the context of HTML attributes, use <b>{{attr: }}</b>.</div><!--上面的內容只是說明作用--><!--對比了{{:name}}和{{>name}}的區別--><script type="text/x-jsrender" id="movieTemplate"><tr title="{{attr:availability}}"><td>{{loc:title lang=‘EN‘}}</td><td>{{loc:title lang=‘FR‘}}</td><td class="synopsis">{{:synopsis}}</td><td class="synopsis">{{>synopsis}}</td></tr></script><!--表格開始--><table><thead><tr><th>Title (loc:English)</th><th>Title (loc:French)</th><th>No Convert</th><th>HTML Encode</th></tr></thead><tbody id="movieList"></tbody></table><!--表格結束--><script type="text/javascript">//Json資料var movies = [{availability: "Available in ‘X&Y‘ Cinemas",title: "Meet Joe Black",synopsis: "The <span class=‘role‘>死神</span> (<a href=‘http://www.netflix.com/RoleDisplay/Brad_Pitt/73919‘>Brad Pitt</a>) visits <span class=‘role‘>Bill Parrish</span> (<a href=‘http://www.netflix.com/RoleDisplay/Anthony_Hopkins/43014‘>Anthony Hopkins</a>)..."},{availability: "Available at < 20kms from London",title: "Eyes Wide Shut",synopsis: "Director <span class=‘director‘>Stanley Kubrick‘s</span> final film: <br/><br/><img src=‘http://cdn-4.nflximg.com/US/boxshots/large/5670434.jpg‘/>"}];//自訂模板$.views.converters({loc: function (value) {var result = "";switch (this.tagCtx.props.lang) {case "EN": result = value; break;case "FR": switch (value) {case "Meet Joe Black":result = "Rencontrez Joe Black";break;case "Eyes Wide Shut":result = "Les Yeux Grand Fermes";break;}break;}return result;}});$("#movieList").html($("#movieTemplate").render(movies));</script></body></html>