首页 > 其他 > 详细

[Jade] Use Mixins in Pug

时间:2017-06-19 23:09:02      阅读:342      评论:0      收藏:0      [点我收藏+]

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

原文:http://www.cnblogs.com/Answer1215/p/7050998.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!