首页 > 代码库 > [Jade] Use Mixins in Pug
[Jade] Use Mixins in Pug
Mixin works as a function.
extends layoutinclude mixins/storeFormblock content .inner h2 #{title} +storeForm({name: ‘NODE‘})
Here, we use include keyword to inlcude a mixin file.
include mixins/storeForm
Exec a mixin function we can use ‘+‘:
+storeForm({name: ‘NODE‘})
Define a mixin:
mixin storeForm(store = {}) form(action="/add" method="POST" class="card") label(for="name") Name input(type="text" name="name") label(for="description") Description textarea(name="description") - const choices = [‘Wifi‘, ‘Open Late‘, ‘Fmaily Friendly‘, ‘Vegatarian‘, ‘Licensed‘]; ul.tags each choice in choices .tag.tag__choice input(type="checkbox" id=choice value=http://www.mamicode.com/choice name="tags") label(for=choice) #{choice} input(type="submit" value="http://www.mamicode.com/Save" class="button")
Here we use some js code:
- const choices = [‘Wifi‘, ‘Open Late‘, ‘Fmaily Friendly‘, ‘Vegatarian‘, ‘Licensed‘];
to hard code some categories.
[Jade] Use Mixins in Pug
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。