multitemplate

package
v0.4.3 Latest Latest
Warning

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

Go to latest
Published: May 2, 2014 License: BSD-2-Clause Imports: 14 Imported by: 0

Documentation

Overview

multitemplate is a package that allows multiple templates written in multiple template languages to call between each other. This is the revel connector for multitemplate. See godoc.org/github.com/acsellers/multitemplate/revel for the integration instructions.

Index

Constants

This section is empty.

Variables

View Source
var (
	// DefaultLayout allows you to set a layout that will automatically be added
	// per content type.
	DefaultLayout = make(map[RequestFormat]string)
	// Template is the template loader used by multitemplate. It will be replaced each
	// time the templates a refreshed if you are using auto-refresh.
	Template *mt.Template
	// In DevMode, multitemplate will automatically
	// refresh templates using revel's Watcher struct,
	// in ProductionMode, you can change ProdRefresh to
	// true to get that behavior. Maybe you're doing
	// something special with FUSE and template folders
	// so you would need this. RefreshPaths will not start
	// watching folders in DevMode without this.
	ProdRefresh bool
	// CurrentError will record any errors encountered when loading templates, so it
	// can be displayed when rendering the page.
	CurrentError error
)
View Source
var ReloadFilter = func(c *revel.Controller, fc []revel.Filter) {
	if watch != nil {
		watch.Notify()
	}

	fc[0](c, fc[1:])
}

Functions

func Init

func Init(helper string)

Init must be called from within revel's OnAppStart method.

func RefreshPaths

func RefreshPaths(morePaths ...string)

If you have added paths for templates beyond the paths accessible in the array revel.TemplatePaths, call this function to pick up those directories autmatically. You can also pass extra paths to this function if you prefer it, and multitemplate will also save and watch those paths.

func RefreshTemplates

func RefreshTemplates() error

RefreshTemplates is automatically called by the auto-refresh system or when you call RefreshPaths.

Types

type Controller

type Controller struct {
	*revel.Controller
	// contains filtered or unexported fields
}

Controller can be added to your controller structs in your revel app to use the multitemplate system.

func (*Controller) Block

func (c *Controller) Block(name string, content template.HTML)

Block sets a pre-rendered HTML string that can show up in a yield or block.

func (*Controller) ContentFor

func (c *Controller) ContentFor(name, templateName string)

ContentFor sets a template to be rendered for a key, this can be used by either a block call or a yield call.

func (*Controller) Render

func (c *Controller) Render(extraRenderArgs ...interface{}) revel.Result

Standard Render call, this renders the default template for this action.

func (*Controller) RenderTemplate

func (c *Controller) RenderTemplate(templateName string) revel.Result

RenderTemplate renders a specific template by path. If a DefaultLayout value is available for this content type, it will be filled in automatically.

func (*Controller) SetLayout

func (c *Controller) SetLayout(name string)

SetLayout sets the layout to be executed for this action. Set it to the empty string to disable the layout for this action.

type RequestFormat

type RequestFormat string
const (
	HTML RequestFormat = "html"
	XML  RequestFormat = "xml"
	JSON RequestFormat = "json"
	TXT  RequestFormat = "txt"
)

Jump to

Keyboard shortcuts

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