zoukankan      html  css  js  c++  java
  • [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.

  • 相关阅读:
    js开发笔记
    安全相关开发笔记
    常用.NET库使用总结
    Windows使用总结
    .NET Web开发笔记
    Unity插件使用总结
    WinForm开发笔记
    C#开发笔记
    iTunes使用总结
    Mac使用总结
  • 原文地址:https://www.cnblogs.com/Answer1215/p/7050998.html
Copyright © 2011-2022 走看看