此包将 Bootstrap 元素封装成方便的 Leaf 标签。
将 Bootstrap
添加到包依赖项中 (在你的 Package.swift
文件中)
dependencies: [
...,
.package(url: "https://github.com/nodes-vapor/bootstrap.git", from: "4.0.0-beta")
]
以及你的目标 (例如 "App")
targets: [
...
.target(
name: "App",
dependencies: [... "Bootstrap" ...]
),
...
]
首先在你的 configure.swift
中导入 Bootstrap 和 Leaf
import Bootstrap
import Leaf
为了渲染 Bootstrap 元素,你需要添加 Bootstrap Leaf 标签
public func configure(_ config: inout Config, _ env: inout Environment, _ services: inout Services) throws {
services.register { _ -> LeafTagConfig in
var tags = LeafTagConfig.default()
tags.useBootstrapLeafTags()
return tags
}
}
#bs:alert() { alert text }
#bs:badge(type?, classExtras?, attributes?) { badge text }
#bs:button(type?, classExtras?, attributes?) { btn text }
#bs:buttonGroup(isVertical, classExtras?, Aria?) { }
#bs:buttonGroup(false, "btn-group-sm") {
#bs:button() { First Option }
#bs:button("danger") { Second Option}
#bs:button() { Third Option}
}
#bs:buttonToolbar(classExtras?, Aria?) { }
#bs:buttonToolbar() {
#bs:button() { First Option }
#bs:button("danger") { Second Option}
#bs:button() { Third Option}
}
#bs:input(type?, classExtras?, attributes?)
#bs:breadcrumb(classExtras?, attributes?) {
#bs:breadcrumbItem(classExtras?, attributes?) { <a href="/"> Home </a> }
#bs:breadcrumbItem(classExtras?, attributes?) { Profile }
}
#bs:textArea(classExtras?, attributes?, value?)
此包由 Vapor 团队在 Nodes 开发和维护。 此项目的负责人是 Martin。
此包是根据 MIT 许可证 授权的开源软件