# README
view
Package view provides template registration, rendering, and helper functions for golang views
Usage
Load templates on app startup:
err := view.LoadTemplates()
if err != nil {
server.Fatalf("Error reading templates %s", err)
}
Render a template
// Set up the view
view := view.New(context)
// Add a key to the view
view.AddKey("page", page)
// Optionally set template, layout or other attributes
view.Template("src/pages/views/home.html.got")
// Render the view
return view.Render()
Public subpackages:
- helpers - utilities for handling files
# Packages
No description provided by the author
Package parser defines an interface for parsers (creating templates) and templates (rendering content), and defines a base template type which conforms to both interfaces and can be included in any templates.
Package translation provides a simple in-memory translation service - it may soon be renamed translate.
# Functions
DefaultHelpers returns a default set of helpers for the app, which can then be extended/replaced.
LoadTemplates loads our templates from ./src, and assigns them to the package variable Templates This function is deprecated and will be removed, use LoadTemplatesAtPaths instead.
LoadTemplatesAtPaths loads our templates given the paths provided.
New creates a new Renderer.
NewRenderer returns a new renderer for this request.
NewWithPath creates a new Renderer with a path and an http.ResponseWriter.
PrintTemplates prints out our list of templates for debug.
ReloadTemplates reloads the templates for our scanner.
# Variables
AuthenticityContext is used as a key to save request authenticity tokens.
Helpers is a list of functions available in templates.
LanguageContext is used as a key to save request lang.
Production is true if this server is running in production mode.
# Structs
Renderer is a view which is set up on each request and renders the response to its writer.
# Interfaces
RenderContext is the type passed in to New, which helps construct the rendering view Alternatively, you can use NewWithPath, which doesn't require a RenderContext.