Skip to content

如何在 Jedi 中编写模板? #8

Open

Description

@cssmagic

方法一

把模板代码写入注释区块中,以避免被转义。

script @type="text/template"
    !
        <ul class="my-list">
        <% _.each(data.list, function (item) { %>
            <li><%= item %><li>
        <% }) %>
        </ul>

方法二

利用 Jedi 来生成结构,使用 :unsafe 来插入模板逻辑和变量。

script @type="text/template"
    ul.list
        :unsafe '<% _.each(data.list, function (item) { %>'
        li
            :unsafe '<%= item %>'
        :unsafe '<% }) %>'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions