These primitives make up Paw's rendering core. Most higher-level widgets eventually compose one or more of these types.
paw.Listpaw.Stringpaw.Htmlpaw.Tagpaw.Boldpaw.PreCodeAPI 接口 |
Description 说明 |
|---|---|
Ui |
The minimal render contract used throughout Paw. Paw 全局通用的最小渲染契约。 |
List |
Renders multiple Ui values in order. 按顺序渲染多个 Ui 值。 |
Html |
Writes trusted raw HTML without escaping. 直接输出可信的原始 HTML,不做转义。 |
Tag |
Builds escaped tags when Paw does not already have a dedicated component. 当 Paw 没有现成组件时,用它构造带转义的 HTML 标签。 |
String, StringNoWrap, Bold |
Escaped text helpers for default text, no-wrap text, and strong emphasis. 用于普通文本、不换行文本和强调文本的转义辅助类型。 |
P, Small, Pre, PreCode |
Paragraph and code-oriented helpers. 面向段落和代码展示的辅助类型。 |
Br, Hr, Vr |
Line, horizontal, and vertical separators. 换行、水平分隔线和垂直分隔元素。 |
H1, H2, H3, Heading |
Heading helpers for quick text or custom heading bodies. 用于快速标题文本或自定义标题内容的辅助类型。 |
Default to escaped primitives and only use Html when the content is fully trusted.
Use escaped text by default, then layer formatting with higher-level helpers.
Small and StringNoWrap are useful inside dense layouts such as tables.
paw.P{paw.String("safe text"), paw.Bold("important")}body := paw.List{
paw.H2("Primitive composition"),
paw.P{
paw.String("Use "),
paw.Bold("escaped text"),
paw.String(" by default."),
},
paw.PreCode{
Language: "go",
Code: "fmt.Println(\"hello\")",
},
}
Tag keeps escaping on attribute names and values. Html skips escaping completely and should be reserved for trusted markup.
paw.Tag{
Name: "div",
Attr: map[string]string{"class": "d-flex align-items-center"},
Body: paw.List{
paw.Badge{Text: "Tag", Color: paw.ColorPrimary},
paw.Vr{},
paw.Html(`<span class="text-success">Trusted raw HTML</span>`),
},
}
Html does no escaping at all. Only pass trusted markup.
Tag is the preferred escape hatch when you just need one HTML element and still want escaped attributes and body content.