Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/templates/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
jquery模板-模板化HTML页面_Jquery_Templates - Fatal编程技术网

jquery模板-模板化HTML页面

jquery模板-模板化HTML页面,jquery,templates,Jquery,Templates,我正在编写一个使用jquery模板生成HTML页面的工具,但它不喜欢某些标记(DOCTYPE、HTML、head)。是否可以将以下内容作为模板: <script id="HtmlPageTemplate" type="text/x-jquery-tmpl"> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-tran

我正在编写一个使用jquery模板生成HTML页面的工具,但它不喜欢某些标记(DOCTYPE、HTML、head)。是否可以将以下内容作为模板:

<script id="HtmlPageTemplate" type="text/x-jquery-tmpl">
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" >
    <head>
       <title>${PageTitle}</title>
       <link rel="stylesheet" href="styles/style.css" type="text/css" media="all" />
       <script src="scripts/script.js">{{html "</sc"+"ript>"}}
       <script>
           function MyFunction(){
           }
       {{html "</sc"+"ript>"}}
    </head>
    <body>
        {{tmpl "#PageBody"}}
    </body>
    </html>
</script>

${PageTitle}
{{html”“}}
函数MyFunction(){
}
{{html”“}}
{{tmpl{PageBody}

我正在使用{{html”“}}}关闭脚本标记,而不关闭模板脚本标记。

我认为这对您很有用:


基本的想法是-至少要替换。。。这是一个更容易的黑客。。英雄联盟
<script id="HtmlPageTemplate" type="text/x-jquery-tmpl">
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" >
    <head>
       <title>${PageTitle}</title>
       <link rel="stylesheet" href="styles/style.css" type="text/css" media="all" />
       @#script src="scripts/script.js">@#/script>
       @#script>
                alert('here');
       @#/script>
    </head>
    <body>
        {{tmpl "#PageBody"}}
    </body>
    </html>
</script>
<div id="output"></div>
$.template('test', $('#HtmlPageTemplate').html().split('@#').join('<'));
$.tmpl('test', data).appendTo($("#output"));