Documentation
¶
Index ¶
- func JSON(data string) *element
- func JavaScript(src string) *element
- func Module(src string) *element
- func New(nodes ...node.Node) *element
- func RawText(content string) *element
- func RawTextf(format string, args ...any) *element
- func Static(content string) *element
- func Text(content string) *element
- func Textf(format string, args ...any) *element
- type Element
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func JSON ¶
func JSON(data string) *element
JSON Creates a script element with JSON data Example: script.JSON("{\"key\": \"value\"}") Renders: <script type="application/json">{"key": "value"}</script>
func JavaScript ¶
func JavaScript(src string) *element
JavaScript Creates a script element explicitly with JavaScript type Example: script.JavaScript("script.js") Renders: <script src="script.js" type="text/javascript"></script>
func Module ¶
func Module(src string) *element
Module Creates a new script element with type="module" for ES6 modules Example: script.Module("app.js") Renders: <script src="app.js" type="module"></script>
func New ¶
New Creates a new script element without any initial attributes Example: script.New() Renders: <script></script>
func RawText ¶
func RawText(content string) *element
RawText Creates a new script element with raw inline JavaScript code as unescaped HTML Example: script.RawText("var x = 1;") Renders: <script>var x = 1;</script>
func RawTextf ¶
RawTextf Creates a new script element with formatted raw text content as unescaped HTML using text.RawTextf Example: script.RawTextf("var %s = %d;", "x", 1) Renders: <script>var x = 1;</script>
func Static ¶
func Static(content string) *element
Static Creates a new script element with static text content Example: script.Static("alert('Hi');") Renders: <script>alert('Hi');</script>