3
下面混入玉模板:巢混入
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 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和如何使它呈現爲第一輸出。
謝謝
這個人從鏈接是非常簡潔,但他是對的。其實我花了一些時間試圖弄清楚他的意思,所以也許這對別人有用。 **您必須在包含mixin的聲明結束時添加塊聲明。** –
您是否有代碼示例? –
我已經不再混入混混了,但我認爲你必須像奧斯卡所說的那樣最後加上「塊」。像鏈接節目一樣,但只有一次。 https://github.com/jadejs/jade/issues/1693 – Avec