Documentation
¶
Index ¶
- Constants
- type NamespaceFS
- type Renderer
- func (r *Renderer) AddFS(namespace string, fsys fs.FS, isGlobal bool) error
- func (r *Renderer) AddGlobal(placeholder string, value any)
- func (r *Renderer) AddNotFound(notfoundPath string)
- func (r *Renderer) BasePath() string
- func (r *Renderer) BasePathHandler() http.HandlerFunc
- func (r *Renderer) Render(_ context.Context, w http.ResponseWriter, name string, data any) error
Constants ¶
const (
ViewSubdirectoryName = "views"
)
ViewSubdirectoryName is the standard subdirectory to be used when adding namespaced templates to the renderer.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type NamespaceFS ¶
NamespaceFS is an implementation of the `fs.FS`, `fs.GlobFS` and `fs.ReadFileFS` interfaces that makes a map of namespaced filesystems look as if they were a single filesystem. This is used to keep the templates from different sub-paths separate, while still being able to access them from a single component.
func (NamespaceFS) AddNamespace ¶
func (t NamespaceFS) AddNamespace(namespace, subdir string, files fs.FS) error
AddNamespace adds the subdir of the passed files under the namespace. Subdir must exist.
func (NamespaceFS) Glob ¶
func (t NamespaceFS) Glob(pattern string) ([]string, error)
Glob implements the fs.GlobFS interface for the namespaced subdirectories.
type Renderer ¶
type Renderer struct {
// contains filtered or unexported fields
}
Renderer implements the necessary magic to render Hotwire Turbo frames and streams. Implements the `echo.Renderer` interface.
func New ¶
New setups a new template renderer. rootPage is the Hotwire wrapping page that should be rendered,
func (*Renderer) AddFS ¶
AddFS adds the templates from the passed filesystem to the template map. The key is the namespace, which is generally the name of the domain providing the views. If isGlobal is true, the namespace is added to the global paths and is accessible from any request for rendering. Global template files should have distinct names, as otherwise it can not be guaranteed which template is chosen.
func (*Renderer) AddGlobal ¶
AddGlobal allows you to add a specific string replacement to the template renderer that will return a string only known at setup-time for a specific placeholder template, i.e. {{ global "basepath" }}
func (*Renderer) AddNotFound ¶
func (*Renderer) BasePathHandler ¶
func (r *Renderer) BasePathHandler() http.HandlerFunc