script

package
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 25, 2026 License: MIT Imports: 24 Imported by: 0

Documentation

Index

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

func New(nodes ...node.Node) *element

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

func RawTextf(format string, args ...any) *element

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>

func Text

func Text(content string) *element

Text Creates a new script element with inline JavaScript code Example: script.Text("console.log('Hello');") Renders: <script>console.log(&#39;Hello&#39;);</script>

func Textf

func Textf(format string, args ...any) *element

Textf Creates a new script element with formatted text content using text.Textf Example: script.Textf("console.log('%s');", "Hello") Renders: <script>console.log(&#39;Hello&#39;);</script>

Types

type Element

type Element = element

Element is an exported alias for the private element type

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL