composite

package
v0.4.1-alpha Latest Latest
Warning

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

Go to latest
Published: Mar 14, 2025 License: MIT Imports: 24 Imported by: 0

Documentation

Index

Constants

View Source
const ErrorPanelTemplate = `` /* 2811-byte string literal not displayed */

errorTemplate is the embedded Go template as a string

Variables

This section is empty.

Functions

func ApiFragmentRenderConfigGetName

func ApiFragmentRenderConfigGetName() string

FragmentConfigGetName returns the HyperBricks type associated with the FragmentConfig.

func FilterAllowedQueryParams

func FilterAllowedQueryParams(req *http.Request, allowedKeys []string) url.Values

FilterAllowedQueryParams returns only the query parameters whose keys are in allowedKeys. If allowedKeys is empty, it returns an empty url.Values (no parameters).

func FragmentConfigGetName

func FragmentConfigGetName() string

FragmentConfigGetName returns the HyperBricks type associated with the FragmentConfig.

func GetTemplateFileContent

func GetTemplateFileContent(templatePath string) (string, error)

getTemplateFileContent attempts to retrieve the template content from the cache. If not found, it reads the file from disk, caches it, and returns the content.

func HeadConfigGetName

func HeadConfigGetName() string

HeadConfigGetName returns the HyperBricks type associated with the HeadConfig.

func HyperMediaConfigGetName

func HyperMediaConfigGetName() string

HyperMediaConfigGetName returns the HyperBricks type associated with the HyperMediaConfig.

func SetHeadersFromHxRequest

func SetHeadersFromHxRequest(config *HxResponse, writer http.ResponseWriter)

func SortCompositeErrors

func SortCompositeErrors(errors []error, sortedKeys []string) []error

func TemplateConfigGetName

func TemplateConfigGetName() string

func TreeRendererConfigGetName

func TreeRendererConfigGetName() string

Types

type APIConfig

type APIConfig struct {
	Endpoint  string                 `` /* 130-byte string literal not displayed */
	Method    string                 `` /* 171-byte string literal not displayed */
	Headers   map[string]string      `` /* 130-byte string literal not displayed */
	Body      string                 `` /* 214-byte string literal not displayed */
	Template  string                 `` /* 161-byte string literal not displayed */
	Inline    string                 `` /* 177-byte string literal not displayed */
	Values    map[string]interface{} `` /* 128-byte string literal not displayed */
	Username  string                 `mapstructure:"username" description:"Username for basic auth" example:"{!{api-render-fragment-username.hyperbricks}}"`
	Password  string                 `mapstructure:"password" description:"Password for basic auth" example:"{!{api-render-fragment-password.hyperbricks}}"`
	Status    int                    `mapstructure:"status" exclude:"true"` // This adds {{.Status}} to the root level of the template data
	SetCookie string                 `mapstructure:"setcookie" description:"Set template for cookie" example:"{!{api-render-fragment-setcookie.hyperbricks}}"`
	// PassCookie       string                 `mapstructure:"passcookie" description:"Pass a cookie in eindpoint request" example:"{!{api-render-setcookie.hyperbricks}}"`
	AllowedQueryKeys []string          `mapstructure:"querykeys" description:"Set allowed proxy query keys" example:"{!{api-render-fragment-querykeys.hyperbricks}}"`
	QueryParams      map[string]string `` /* 140-byte string literal not displayed */
	JwtSecret        string            `` /* 230-byte string literal not displayed */
	JwtClaims        map[string]string `mapstructure:"jwtclaims" description:"jwt claim map" example:"{!{api-render-fragment-jwt-claims.hyperbricks}}"`
	Debug            bool              `mapstructure:"debug" description:"Debug the response data" example:"{!{api-render-fragment-debug.hyperbricks}}"`
	DebugPanel       bool              `` /* 199-byte string literal not displayed */
}

type ApiFragmentRenderConfig

type ApiFragmentRenderConfig struct {
	shared.Composite   `mapstructure:",squash"`
	APIConfig          `mapstructure:",squash"`
	HxResponse         ``                  /* 129-byte string literal not displayed */
	MetaDocDescription string              `` /* 233-byte string literal not displayed */
	HxResponseWriter   http.ResponseWriter `mapstructure:"hx_response" exclude:"true"`
	Title              string              `mapstructure:"title" description:"The title of the fragment" example:"{!{api-fragment-render-title.hyperbricks}}"`
	Route              string              `` /* 140-byte string literal not displayed */
	Section            string              `` /* 127-byte string literal not displayed */
	Enclose            string              `` /* 142-byte string literal not displayed */
	NoCache            bool                `mapstructure:"nocache" description:"Explicitly deisable cache" example:"{!{api-fragment-render-nocache.hyperbricks}}"`
	Index              int                 `` /* 205-byte string literal not displayed */
}

FragmentConfig represents configuration for a single fragment.

func (*ApiFragmentRenderConfig) Validate

func (conf *ApiFragmentRenderConfig) Validate() []error

Validate ensures that the fragment has valid data.

type ApiFragmentRenderer

type ApiFragmentRenderer struct {
	renderer.CompositeRenderer
}

ApiFragmentRenderer handles rendering of PAGE content.

func (*ApiFragmentRenderer) Render

func (pr *ApiFragmentRenderer) Render(instance interface{}, ctx context.Context) (string, []error)

Render implements the RenderComponent interface.

func (*ApiFragmentRenderer) Types

func (r *ApiFragmentRenderer) Types() []string

type FragmentConfig

type FragmentConfig struct {
	shared.Composite   `mapstructure:",squash"`
	HxResponse         `mapstructure:"response" description:"HTMX response header configuration." example:"{!{fragment-response.hyperbricks}}"`
	MetaDocDescription string                 `` /* 222-byte string literal not displayed */
	HxResponseWriter   http.ResponseWriter    `mapstructure:"hx_response" exclude:"true"`
	Title              string                 `mapstructure:"title" description:"The title of the fragment" example:"{!{fragment-title.hyperbricks}}"`
	Route              string                 `` /* 129-byte string literal not displayed */
	Section            string                 `mapstructure:"section" description:"The section the fragment belongs to" example:"{!{fragment-section.hyperbricks}}"`
	Items              map[string]interface{} `mapstructure:",remain"`
	Enclose            string                 `` /* 131-byte string literal not displayed */
	Template           map[string]interface{} `` /* 133-byte string literal not displayed */
	IsStatic           bool                   `mapstructure:"isstatic" exclude:"true"`
	Static             string                 `mapstructure:"static" description:"Static file path associated with the fragment" example:"{!{fragment-static.hyperbricks}}"`
	Cache              string                 `mapstructure:"cache" description:"Cache expire string" example:"{!{fragment-cache.hyperbricks}}"`
	NoCache            bool                   `mapstructure:"nocache" description:"Explicitly deisable cache" example:"{!{fragment-nocache.hyperbricks}}"`
	Index              int                    `` /* 194-byte string literal not displayed */
}

FragmentConfig represents configuration for a single fragment.

func (*FragmentConfig) Validate

func (fragment *FragmentConfig) Validate() []error

Validate ensures that the fragment has valid data.

type FragmentRenderer

type FragmentRenderer struct {
	renderer.CompositeRenderer
}

FragmentRenderer handles rendering of PAGE content.

func (*FragmentRenderer) Render

func (pr *FragmentRenderer) Render(instance interface{}, ctx context.Context) (string, []error)

Render implements the RenderComponent interface.

func (*FragmentRenderer) Types

func (r *FragmentRenderer) Types() []string

type HeadConfig

type HeadConfig struct {
	shared.Composite `mapstructure:",squash"`
	Title            string            `mapstructure:"title" description:"The title of the hypermedia document" example:"{!{head-title.hyperbricks}}"`
	Favicon          string            `mapstructure:"favicon" description:"Path to the favicon for the hypermedia document" example:"{!{head-favicon.hyperbricks}}"`
	MetaData         map[string]string `mapstructure:"meta" description:"Metadata for the head section" example:"{!{head-meta.hyperbricks}}"`
	Css              []string          `mapstructure:"css" description:"CSS files to include" example:"{!{head-css.hyperbricks}}"`
	Js               []string          `mapstructure:"js" description:"JavaScript files to include" example:"{!{head-js.hyperbricks}}"`
}

HeadConfig represents the configuration for the head section.

func (*HeadConfig) Validate

func (config *HeadConfig) Validate() []error

Validate ensures that the RENDER has valid data.

type HeadRenderer

type HeadRenderer struct {
	renderer.CompositeRenderer
}

HeadRenderer handles rendering of COA content.

func (*HeadRenderer) Render

func (cr *HeadRenderer) Render(instance interface{}, ctx context.Context) (string, []error)

Render implements the RenderComponent interface for COA.

func (*HeadRenderer) Types

func (r *HeadRenderer) Types() []string

type HxResponse

type HxResponse struct {
	HxTemplateResult     string // just for output of the parsed template
	HxLocation           string `` /* 139-byte string literal not displayed */
	HxPushedUrl          string `mapstructure:"hx_push_url" header:"HX-Pushed-Url" description:"pushes a new url into the history stack"`
	HxRedirect           string `mapstructure:"hx_redirect" header:"HX-Redirect" description:"can be used to do a client-side redirect to a new location"`
	HxRefresh            string `` /* 127-byte string literal not displayed */
	HxReplaceUrl         string `mapstructure:"hx_replace_url" header:"HX-Replace-Url" description:"replaces the current url in the location bar"`
	HxReswap             string `mapstructure:"hx_reswap" header:"HX-Reswap" description:"allows you to specify how the response will be swapped"`
	HxRetarget           string `mapstructure:"hx_retarget" header:"HX-Retarget" description:"a css selector that updates the target of the content update"`
	HxReselect           string `` /* 154-byte string literal not displayed */
	HxTrigger            string `mapstructure:"hx_trigger" header:"HX-Trigger" description:"allows you to trigger client-side events"`
	HxTriggerafterSettle string `` /* 149-byte string literal not displayed */
	HxTriggerafterSwap   string `` /* 143-byte string literal not displayed */
}

type HyperMediaConfig

type HyperMediaConfig struct {
	shared.Composite   `mapstructure:",squash"`
	MetaDocDescription string                 `mapstructure:"@doc" description:"HYPERMEDIA description" example:"{!{hypermedia-@doc.hyperbricks}}"`
	Title              string                 `mapstructure:"title" description:"The title of the hypermedia site" example:"{!{hypermedia-title.hyperbricks}}"`
	Route              string                 `` /* 133-byte string literal not displayed */
	Section            string                 `` /* 177-byte string literal not displayed */
	Items              map[string]interface{} `mapstructure:",remain"`
	BodyTag            string                 `` /* 257-byte string literal not displayed */
	Enclose            string                 `` /* 127-byte string literal not displayed */
	Favicon            string                 `mapstructure:"favicon" description:"Path to the favicon for the hypermedia" example:"{!{hypermedia-favicon.hyperbricks}}"`
	Template           map[string]interface{} `` /* 177-byte string literal not displayed */
	IsStatic           bool                   `mapstructure:"isstatic" exclude:"true"`
	Cache              string                 `mapstructure:"cache" description:"Cache expire string" example:"{!{hypermedia-cache.hyperbricks}}"`
	NoCache            bool                   `mapstructure:"nocache" description:"Explicitly deisable cache" example:"{!{hypermedia-nocache.hyperbricks}}"`
	Static             string                 `` /* 179-byte string literal not displayed */
	Index              int                    `` /* 216-byte string literal not displayed */
	Doctype            string                 `mapstructure:"doctype" description:"Alternative Doctype for the HTML document" example:"{!{hypermedia-doctype.hyperbricks}}"`
	HtmlTag            string                 `mapstructure:"htmltag" description:"The opening HTML tag with attributes" example:"{!{hypermedia-htmltag.hyperbricks}}"`
	Head               map[string]interface{} `` /* 130-byte string literal not displayed */
}

HyperMediaConfig represents configuration hypermedia.

func (*HyperMediaConfig) Validate

func (hm *HyperMediaConfig) Validate() []error

Validate ensures that the page has valid data.

type HyperMediaRenderer

type HyperMediaRenderer struct {
	renderer.CompositeRenderer
}

HyperMediaRenderer handles rendering of PAGE content.

func (*HyperMediaRenderer) Render

func (pr *HyperMediaRenderer) Render(instance interface{}, ctx context.Context) (string, []error)

Render implements the RenderComponent interface.

func (*HyperMediaRenderer) Types

func (r *HyperMediaRenderer) Types() []string

type TemplateConfig

type TemplateConfig struct {
	shared.Composite   `mapstructure:",squash"`
	MetaDocDescription string            `mapstructure:"@doc" description:"TEMPLATE description" example:"{!{template-@doc.hyperbricks}}"`
	Template           string            `` /* 150-byte string literal not displayed */
	Inline             string            `` /* 166-byte string literal not displayed */
	AllowedQueryKeys   []string          `mapstructure:"querykeys" description:"Set allowed proxy query keys" example:"{!{template-querykeys.hyperbricks}}"`
	QueryParams        map[string]string `` /* 129-byte string literal not displayed */

	Values  map[string]interface{} `mapstructure:"values" description:"Key-value pairs for template rendering" example:"{!{template-values.hyperbricks}}"`
	Enclose string                 `` /* 132-byte string literal not displayed */
}

TemplateConfig represents the configuration for a TEMPLATE type.

func (*TemplateConfig) Validate

func (head *TemplateConfig) Validate() []error

type TemplateRenderer

type TemplateRenderer struct {
	renderer.CompositeRenderer
}

func (*TemplateRenderer) Render

func (tr *TemplateRenderer) Render(instance interface{}, ctx context.Context) (string, []error)

func (*TemplateRenderer) Types

func (r *TemplateRenderer) Types() []string

type TreeConfig

type TreeConfig struct {
	shared.Composite   `mapstructure:",squash"`
	MetaDocDescription string `` /* 170-byte string literal not displayed */
	Enclose            string `mapstructure:"enclose" description:"Wrapping property for the tree" example:"{!{tree-enclose.hyperbricks}}"`
}

TreeConfig

func (*TreeConfig) Validate

func (config *TreeConfig) Validate() []error

type TreeRenderer

type TreeRenderer struct {
	renderer.CompositeRenderer
}

func (*TreeRenderer) Render

func (r *TreeRenderer) Render(data interface{}, ctx context.Context) (string, []error)

Concurrent and Recursive Renderer and returns the result and errors. This function is a blueprint function for all concurent rendering of pages, render and template objects

func (*TreeRenderer) Types

func (r *TreeRenderer) Types() []string

Jump to

Keyboard shortcuts

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