bdi

package
v0.3.2 Latest Latest
Warning

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

Go to latest
Published: May 5, 2026 License: MIT Imports: 21 Imported by: 0

Documentation

Overview

Package bdi provides constructors and methods for the HTML <bdi> element.

The <bdi> HTML element isolates text from its surrounding bidirectional text context, preventing it from affecting the directionality of adjacent text. Essential when embedding dynamic content of unknown directionality (like usernames or user-generated content) within text that might be right-to-left (RTL) or left-to-right (LTR). Prevents layout issues in multilingual applications.

Index

Constants

This section is empty.

Variables

View Source
var (
	TagOpen  = []byte("<bdi")
	TagClose = []byte("</bdi>")
)

Byte constants for HTML rendering.

Functions

func New

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

New creates a new bdi element with the given child nodes. Example: bdi.New(text.Text("username")) Renders: <bdi>username</bdi>

func RawText

func RawText(str string) *element

RawText creates a new bdi element with raw text content as unescaped HTML. Example: bdi.RawText("<span>User</span>") Renders: <bdi><span>User</span></bdi>

func RawTextf

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

RawTextf creates a new bdi element with formatted raw text content as unescaped HTML using text.RawTextf. Example: bdi.RawTextf("<strong>%s</strong>", "User") Renders: <bdi><strong>User</strong></bdi>

func Static

func Static(str string) *element

Static creates a new bdi element with static text content. Example: bdi.Static("User123") Renders: <bdi>User123</bdi>

func Text

func Text(str string) *element

Text creates a new bdi element with text content (HTML-encoded). Example: bdi.Text("אילנה") Renders: <bdi>אילנה</bdi>

func Textf

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

Textf creates a new bdi element with formatted text content using text.Textf. Example: bdi.Textf("User: %s", "username") Renders: <bdi>User: username</bdi>

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