helpers

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 15, 2023 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package helpers provides utility functions and types to simplify and enhance the creation and manipulation of godom elements and attributes.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FlagAttribute

func FlagAttribute(flag string) types.Attribute

FlagAttribute creates an attribute that acts as a flag (i.e., key without a value). Example usage for boolean attributes: FlagAttribute("disabled")

func MultiValueAttribute

func MultiValueAttribute(key string, values ...string) types.Attribute

MultiValueAttribute creates an attribute with a key that can hold multiple space-separated values. If the attribute already exists, the new values are appended. Example usage for a class attribute: MultiValueAttribute("class", "btn", "btn-primary")

func NewChildlessElement

func NewChildlessElement(tag string, attrs ...types.Attribute) types.Element

NewChildlessElement creates a new types.Element that cannot have child elements. It initializes the element with the provided tag and any additional attributes. Example usage: NewChildlessElement("br", someAttribute)

func NewElement

func NewElement(tag string, attrs ...types.Attribute) types.ElementFactory

NewElement creates a factory function for a new types.Element with the given tag and attributes. The factory function, when called, will produce an element with the specified child elements. Example usage: Div := NewElement("div"); divElement := Div(child1, child2)

func NewStringElement

func NewStringElement(content string) types.Element

NewStringElement creates a new element that holds a static string as its content.

func SingleAttribute

func SingleAttribute(key, value string) types.Attribute

SingleAttribute creates an attribute with a single key-value pair. If the attribute with the same key already exists with a different value, it panics.

Types

This section is empty.

Jump to

Keyboard shortcuts

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