fhtml

package module
v0.0.0-...-771095e Latest Latest
Warning

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

Go to latest
Published: Dec 31, 2024 License: MIT Imports: 4 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

fhtml

Functional HTML builder for Go (Golang)

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Indent = `  `
)

Functions

func Foreach

func Foreach[T any](data []T, fn func(key int, value T) bool) *struct{}

Foreach iterates through slice executing callback for each member

Types

type BaseComponent

type BaseComponent struct{}

type BaseLayout

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

func (*BaseLayout) Content

func (l *BaseLayout) Content() Renderer

func (*BaseLayout) Data

func (l *BaseLayout) Data() []byte

func (*BaseLayout) Layout

func (l *BaseLayout) Layout() Renderer

func (*BaseLayout) Render

func (l *BaseLayout) Render(b *Builder) *Builder

func (*BaseLayout) SetContent

func (l *BaseLayout) SetContent(content Renderer) Renderer

func (*BaseLayout) SetData

func (l *BaseLayout) SetData(data []byte) Renderer

func (*BaseLayout) SetLayout

func (l *BaseLayout) SetLayout(layout Renderer) Renderer

type BaseView

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

func (*BaseView) Data

func (v *BaseView) Data() []byte

func (*BaseView) Layout

func (v *BaseView) Layout() Renderer

func (*BaseView) Render

func (v *BaseView) Render(b *Builder) *Builder

func (*BaseView) Run

func (v *BaseView) Run(b *Builder)

func (*BaseView) SetData

func (v *BaseView) SetData(data []byte) Renderer

func (*BaseView) SetLayout

func (v *BaseView) SetLayout(layout Renderer) Renderer

type Builder

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

func NewBuilder

func NewBuilder() *Builder

NewBuilder constructs *Builder provided 'data' argument is valid JSON

func (*Builder) Attr

func (b *Builder) Attr(vals ...string) string

Attr writes HTML attribute

func (*Builder) Bytes

func (b *Builder) Bytes() []byte

Bytes returns []byte form Buffer

func (*Builder) Children

func (b *Builder) Children(tags ...any) *Builder

Children builds child elements

func (*Builder) ChildrenInline

func (b *Builder) ChildrenInline(tags ...any) *Builder

ChildrenInline builds inline child elements

func (*Builder) Class

func (b *Builder) Class(vals ...string) string

Class writes HTML class attribute

func (*Builder) Close

func (b *Builder) Close()

Close destroys Buffer

func (*Builder) Document

func (b *Builder) Document(tags ...any) *Builder

Document creates base HTML document

func (*Builder) Foreach

func (b *Builder) Foreach(data []byte, path string, fn func(key, value gjson.Result)) *struct{}

Foreach extracts array from JSON data for provided 'path' and executes 'fn' for each array member

func (*Builder) GetBool

func (b *Builder) GetBool(data []byte, path string) bool

GetBool extracts bool value from JSON data given provided path

func (*Builder) GetString

func (b *Builder) GetString(data []byte, path string) string

GetString extracts string value from JSON data given provided path

func (*Builder) HTML

func (b *Builder) HTML(tokens ...string) *Builder

HTML writes indented raw strings - not sanitized HTML

func (*Builder) HTMLInline

func (b *Builder) HTMLInline(tokens ...string) *Builder

HTMLInline writes raw strings inline - not sanitized HTML

func (*Builder) If

func (b *Builder) If(expression bool, s string) string

If executes 'fn' if result of 'expression' is true

func (*Builder) IfFunc

func (b *Builder) IfFunc(expression bool, fn func()) *struct{}

IfFunc executes 'fn' if result of 'expression' is true

func (*Builder) SetData

func (b *Builder) SetData(data []byte, path string, value interface{}) []byte

SetData builds JSON

func (*Builder) String

func (b *Builder) String() string

String returns string form Buffer

func (*Builder) Tag

func (b *Builder) Tag(tag string, attrs ...string) *Builder

Tag builds HTML element

func (*Builder) TagInline

func (b *Builder) TagInline(tag string, attrs ...string) *Builder

TagInline builds inline HTML element

func (*Builder) Text

func (b *Builder) Text(text string) *Builder

Text writes indented sanitized text

func (*Builder) TextInline

func (b *Builder) TextInline(text string) *Builder

TextInline writes sanitized text inline

func (*Builder) Void

func (b *Builder) Void() *Builder

Void prevents closing void tab

func (*Builder) WriteString

func (b *Builder) WriteString(s ...string) *struct{}

WriteString returns string form Buffer

type BuilderFn

type BuilderFn func(b *Builder) *struct{}

type Renderer

type Renderer interface {
	Data() []byte
	SetData(data []byte) Renderer
	Layout() Renderer
	SetLayout(layout Renderer) Renderer
	Render(b *Builder) *Builder
}

Renderer is interface for views and layouts

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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