tag

package
v5.6.0 Latest Latest
Warning

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

Go to latest
Published: Nov 29, 2023 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package tag provides the data type for (X)HTML tags/DOM nodes.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Tag

type Tag struct {
	// contains filtered or unexported fields
}

Tag represents an HTML tag/DOM node.

func NewClosed

func NewClosed(name string) Tag

NewClosed returns a new closed tag.

func NewUnclosed

func NewUnclosed(name string) Tag

NewUnclosed returns a new unclosed tag.

func NewWrapper

func NewWrapper() Tag

NewWrapper returns a new wrapper tag.

func (Tag) Lines

func (t Tag) Lines() (res []lines.Line)

Lines returns rendered lines of the tag.

func (Tag) String

func (t Tag) String() string

String returns a string representation of the tag.

func (Tag) WithAttrs

func (t Tag) WithAttrs(attributes map[string]string) Tag

WithAttrs return the tag but with the given attributes. Previous attributes of the tag are discarded.

This is a no-op for wrapper tags.

func (Tag) WithChildren

func (t Tag) WithChildren(children ...Tag) Tag

WithChildren returns the tag but with the given children. Previous children of the tag are discarded.

This is a no-op for unclosed tags.

func (Tag) WithContentsLines

func (t Tag) WithContentsLines(lines ...lines.Line) Tag

WithContentsLines returns the tag but with the given lines of contents.

Contents is like children, but just text, not tags.

This is a no-op for unclosed tags.

func (Tag) WithContentsStrings

func (t Tag) WithContentsStrings(strs ...string) Tag

WithContentsStrings is like WithContentsLines but it wraps strings into indented lines for you.

Jump to

Keyboard shortcuts

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