Mustache Template doesn't render inside table tbody

。_饼干妹妹 提交于 2019-12-05 01:49:42

divTable.innerHTML returns this instead of correct template. Probably it's happens because browser tries to render invalid HTML. I think you can put your template into <script> tag to solve this problem (the fiddle)

You can also comment mustache tags in tbody. And table will built correctly.
My template example:

<div id="template-table">
    <table>
        <thead>
            <th>Name</th>
            <th>Age</th>
        </thead>
        <tbody>
        <!--{{#students}}-->
            <tr>
                <td>{{name}}</td>
                <td>{{age}}</td>
            </tr>
        <!--{{/students}}-->
        </tbody>
    </table>
</div>
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!