media

package
v1.7.4 Latest Latest
Warning

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

Go to latest
Published: Jul 8, 2026 License: GPL-2.0 Imports: 5 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AddableMedia

type AddableMedia interface {
	// AddJS adds a JS asset to the media.
	AddJS(js ...Asset)

	// AddCSS adds a CSS asset to the media.
	AddCSS(css ...Asset)
}

type Asset

type Asset interface {
	String() string
	Render() template.HTML
}

type CSS

type CSS string

func (CSS) Render

func (c CSS) Render() template.HTML

func (CSS) String

func (c CSS) String() string

type JS

type JS string

func (JS) Render

func (j JS) Render() template.HTML

func (JS) String

func (j JS) String() string

type JSAsset

type JSAsset struct {
	Type string
	URL  string
}

func (*JSAsset) Render

func (j *JSAsset) Render() template.HTML

func (*JSAsset) String

func (j *JSAsset) String() string

type Media

type Media interface {
	// Merge merges the media of the other Media object into this one.
	// It returns the merged Media object - it modifies the receiver.
	Merge(other Media) Media

	// A list of JS script tags to include.
	JS() []template.HTML

	// A list of CSS link tags to include.
	CSS() []template.HTML

	// The list of raw JS urls to include.
	JSList() []Asset

	// The list of raw CSS urls to include.
	CSSList() []Asset

	AddableMedia
}

type MediaDefiner

type MediaDefiner interface {
	Media() Media
}

type MediaObject

type MediaObject struct {
	Css *orderedmap.OrderedMap[string, Asset]
	Js  *orderedmap.OrderedMap[string, Asset]
}

func NewMedia

func NewMedia() *MediaObject

func (*MediaObject) AddCSS

func (m *MediaObject) AddCSS(list ...Asset)

func (*MediaObject) AddJS

func (m *MediaObject) AddJS(list ...Asset)

func (*MediaObject) CSS

func (m *MediaObject) CSS() []template.HTML

func (*MediaObject) CSSList

func (m *MediaObject) CSSList() []Asset

func (*MediaObject) JS

func (m *MediaObject) JS() []template.HTML

func (*MediaObject) JSList

func (m *MediaObject) JSList() []Asset

func (*MediaObject) Merge

func (m *MediaObject) Merge(other Media) Media

func (*MediaObject) String

func (m *MediaObject) String() string

type PriorityAsset added in v1.7.2

type PriorityAsset struct {
	Asset
	Importance int // The higher the priority, the earlier it is included.
}

func AssetWithPriority added in v1.7.2

func AssetWithPriority(asset Asset, priority int) *PriorityAsset

func (*PriorityAsset) Priority added in v1.7.2

func (p *PriorityAsset) Priority() int

type WeightedAsset added in v1.7.2

type WeightedAsset interface {
	Asset
	Priority() int // The higher the priority, the earlier it is included.
}

Jump to

Keyboard shortcuts

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