[Jade] Use Mixins in Pug
Posted Answer1215
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了[Jade] Use Mixins in Pug相关的知识,希望对你有一定的参考价值。
Mixin works as a function.
extends layout include mixins/storeForm block 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=choice name="tags") label(for=choice) #{choice} input(type="submit" value="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的主要内容,如果未能解决你的问题,请参考以下文章