Handlebars.js编译前置和附加" //"输出

时间:2016-09-14 16:07:47

标签: javascript jquery handlebars.js

感谢对此的帮助。令人沮丧的是,我无法理解这一点。看一下下面的截图。查看将内容夹在中间的开头和尾部斜杠?无法弄清楚为什么这些都包含在输出中。有什么想法吗?

谢谢!

这里是js:

var source = $j("#src").html();
var template = Handlebars.compile(source, preventIndent);
var output = template(data);       
$j("#data-wrapper").html(output);

这是html:

<div id="data-wrapper"></div>
<script id="src" type="text/x-handlebars-template">
    <table class="table table-striped table-responsive">
        <thead>
            <tr>
                <td>Number</td>
            </tr>
        </thead>
        <tbody>
            {{#each this}}
                <tr>
                    <td>{{number}}</td> 
                </tr>
             {{/each}}
        </tbody>
    </table>
</script>

以及我得到的内容:

<div id="data-wrapper" style="min-height: 500px; position: relative;">//  

    <table class="table table-striped table-responsive">
        <thead>
            <tr>
                <td>Number</td>
                <td>Short Description</td>
            </tr>
        </thead>
        <tbody>
                <tr>
                    <td>ENHC0010005</td> 
                    <td>Enable module relationships to the Enhancement and Defect forms.</td>
                </tr>
                <tr>
                    <td>ENHC0010010</td> 
                    <td>This is a short description which will display as the body text of a slack message...hopefully.</td>
                </tr>
                <tr>
                    <td>ENHC0010014</td> 
                    <td>This is a short description which will display as the body text of a slack message...hopefully.</td>
                </tr>
                <tr>
                    <td>ENHC0010015</td> 
                    <td></td>
                </tr>
                <tr>
                    <td>ENHC0010017</td> 
                    <td>This is the short description</td>
                </tr>
                <tr>
                    <td>ENHC0010018</td> 
                    <td>Short description here</td>
                </tr>
                <tr>
                    <td>ENHC0010020</td> 
                    <td></td>
                </tr>
                <tr>
                    <td>ENHC0010021</td> 
                    <td>Another test of new channel name</td>
                </tr>
                <tr>
                    <td>ENHC0010026</td> 
                    <td>Application Access fulfillment request</td>
                </tr>
                <tr>
                    <td>ENHC0010029</td> 
                    <td>Application Access fulfillment request</td>
                </tr>
        </tbody>
    </table>
//</div>    

数据结构:

enter image description here

0 个答案:

没有答案