echorenderer

package module
v0.1.0-beta.1 Latest Latest
Warning

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

Go to latest
Published: Aug 9, 2024 License: MIT Imports: 5 Imported by: 1

README

.github/workflows/build.yml Go Reference

echo-renderer

A basic implementation of echo.Renderer using html/template.

Usage

The echo-renderer package is designed to be used in applications where shared templates are used in conjunction with page templates to compose complete HTML documents. Using html/template, this is achieved by overriding a shared template block nodes with the target template content.

As such, custom template names are not supported for the target page template (i.e., a page template must be referred to by its filename).

In order to use echo-renderer, simple create and assign a new echorenderer.Renderer to the router's Renderer property. See the examples directory for more information.

License

MIT License

Copyright (c) 2024 Brian Reece

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

Documentation

Overview

Package echorenderer provides an implementation of echo.Renderer using html/template.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNoInclude = errors.New("echorenderer: must have at least one include pattern")
	ErrNoFS      = errors.New("echorenderer: must have filesystem")
)

Functions

This section is empty.

Types

type FuncMapper

type FuncMapper func(c echo.Context) template.FuncMap

Creates a template.FuncMap using an echo.Context.

type Options

type Options struct {
	// An [fs.FS] that contains the templates.
	FS fs.FS
	// The glob patterns used in [template.Parse].
	Include []string
	// An optional [FuncMapper].
	Funcs FuncMapper
}

Provides configuration for Renderer.

type Renderer

type Renderer struct {
	*template.Template
	// contains filtered or unexported fields
}

Provides echo.Renderer implementation through template.Template.

func New

func New(opts *Options) (*Renderer, error)

Creates a new Renderer.

func (*Renderer) Render

func (r *Renderer) Render(w io.Writer, name string, data any, c echo.Context) error

Render implements echo.Renderer.

Directories

Path Synopsis
examples
basic command
subdirectory command

Jump to

Keyboard shortcuts

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