码迷,mamicode.com
首页 > 其他好文 > 详细

[Jade] Use Mixins in Pug

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

标签:node   each   div   for   sed   function   add   log   code   

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

标签:node   each   div   for   sed   function   add   log   code   

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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!