UNPKG

lite

Version:

A cross platform template engine base on xml/html and javascript expression.

71 lines (69 loc) 1.45 kB
<test format="true"> <unit title="自定义语法扩展"> <model> { array:[1,2,3,'4',5.5,'',true,null,false,[1,2],{a:1,b:2},[]], string:"JSON 功能测试'\"", object:{aa:1,bB:2,CC:[1]} } </model> <case title="扩展html标签"> <source><![CDATA[ <html> <body> <c:extension namespace="http://www.w3.org/1999/xhtml"> function parseA(node){ this.appendText('[') this.next(node) this.appendText(']') } function onhref(href){ href.value='?'+href.value; this.next(href) } </c:extension> <a href="#a">a</a>, <a href="#b">b</a> </body> </html>]]></source> <expect><![CDATA[<html> <body> [<a href="?#a">a</a>], [<a href="?#b">b</a>] </body> </html> ]]></expect> </case> <case title="扩展自定义名称空间"> <source><![CDATA[ <html> <c:extension namespace="http://www.xidea.org/lite/example"><![CDATA[ function parseString(node){ var text = String(node.textContent || node.text); text = text.replace(/^\s+|\s+$/g,''); var varName = node.getAttribute('var'); this.appendText("<script>var " +varName+'='+JSON.stringify(text) +";<\/script>"); } ]]]]><![CDATA[> </c:extension> <body xmlns:x="http://www.xidea.org/lite/example"> <x:string var="source"> <![CDATA[ <div class="test"> </div> ]]]]><![CDATA[> </x:string> </body> </html>]]></source> <expect><![CDATA[ <html> <body> <script>var source="<div class=\"test\">\n</div>";</script> </body> </html> ]]></expect> </case> </unit> </test>