assets

package
v0.14.4 Latest Latest
Warning

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

Go to latest
Published: Mar 18, 2024 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var InternalFiles embed.FS
View Source
var PublicFiles embed.FS

Functions

func NewRenderData

func NewRenderData(app *pocketbase.PocketBase) map[string]any

NewRenderData creates and returns a map containing render data for the given app. The render data includes the environment variable "WGA_ENV" and the contents of the "analytics.txt" file. If the "renderable:analytics" cache is not available, the file is read and stored in the cache. The "Analytics" key in the map contains the contents of the "analytics.txt" file.

func Render

func Render(r Renderable) (string, error)

Render renders a Renderable object and returns the resulting HTML string. If the Renderable object is marked as htmx, it renders the block using RenderBlock. Otherwise, it renders the page using RenderPage.

func RenderBlock

func RenderBlock(block string, data map[string]any) (string, error)

renderBlock renders a given block of HTML using the provided data and returns the resulting HTML string. The function searches for HTML templates in the "views/pages" and "views/partials" directories of the InternalFiles filesystem. It uses the utils.TemplateFuncs map to provide additional functions to the templates. If an error occurs while parsing or rendering the template, the function returns an empty string and the error.

func RenderEmail

func RenderEmail(t string, data map[string]any) (string, error)

RenderEmail renders an email template with the given data. The function takes a string `t` representing the template name and a map `data` containing the data to be rendered. It returns a string representing the rendered email and an error if any occurred.

func RenderPage

func RenderPage(t string, data map[string]any) (string, error)

renderPage renders the given template with the provided data and returns the resulting HTML string. The template is parsed from the views directory using the provided template name and the layout.html file. If the template cannot be parsed or there is an error rendering it, an error is returned.

func RenderPageWithLayout

func RenderPageWithLayout(t string, layout string, data map[string]any) (string, error)

Types

type Renderable

type Renderable struct {
	IsHtmx bool
	Page   string
	Block  string
	Data   map[string]any
}

Directories

Path Synopsis
templ

Jump to

Keyboard shortcuts

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