javascript - Jade 模板 : nest mixin

标签 javascript express pug

混入下方

mixin form(title, action)
    legend title
    form.form-horizontal(method='post', action=action)
        label Name:
        input(type='text',name=Name,id=Name)

呈现给

<legend>title</legend>
<form method="post" action="save" class="form-horizontal">
  <label>Name:</label>
  <input type="text"/>
</form>

现在,我将标签和字段提取到另一个 mixin 中

mixin form(title, action)
    legend title
    form.form-horizontal(method='post', action=action)

mixin field(name)
    label #{name}:
    input(type='text',name=name,id=name)

并用作

mixin form("xxxx", "save")
    mixin field('Name')

这给出了错误

>> Line 1209: Unexpected string
Warning: Jade failed to compile test.jade. Use --force to continue.

是否可以嵌套 mixin 以及如何使其呈现为第一个输出。

谢谢

最佳答案

看来应该可以。至少这里的人能够做到。

https://github.com/pugjs/pug/issues/1103

关于javascript - Jade 模板 : nest mixin,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17396835/

相关文章:

javascript - 在 YUI 中获取点击项的索引

javascript - 我怎样才能用angularjs重定向

javascript - 如何使用 multer 或 body-parser 上传文件

javascript - 网站加载时间的脚本

javascript - node.js express-session 是无状态的还是有状态的?

javascript - 如何使用bind传递对next()的引用?

javascript - Jade Mixin - 对象操作

javascript - 如何避免 NodeJs、Express 中的 If else hell

node.js - 如何从 json 有效负载获取 iframe 以在 pug 中渲染?

javascript - 无法使用 Jade 模板包含相对路径文件