Esempio n. 1
0
//Renders the application template; yielding to app layout if requested.
func Render(controllerName, actionName string, viewData *ViewData) string {
	layoutFile := fmt.Sprintf("app/views/%s.template", "application")
	filename := fmt.Sprintf("app/views/%s/%s.template", controllerName, actionName)

	yieldFn := func(params []string, data string) string {
		yieldOut := mustache.RenderFile(filename, viewData.Context)

		return yieldOut
	}

	viewData.Yield = yieldFn

	out := mustache.RenderFile(layoutFile, viewData)

	return out
}
Esempio n. 2
0
// Renders the requested template inside a layout. This can override the
// default behavior to render inside the application layout.
func RenderIn(templateName, controllerName, actionName string, viewData *ViewData) string {
	layoutFile := fmt.Sprintf("app/views/%s.template", templateName)
	filename := fmt.Sprintf("app/views/%s/%s.template", controllerName, actionName)

	yieldFn := func(params []string, data string) string {
		yieldOut := mustache.RenderFile(filename, viewData.Context, getHelpers(), getFormHelpers())

		return yieldOut
	}

	viewData.Yield = yieldFn

	out := mustache.RenderFile(layoutFile, viewData, getHelpers())

	return out
}
Esempio n. 3
0
// Renders a mustache template from the views/ directory
func RenderTo(templateName string, viewData *ViewData) string {
	filename := "app/views/" + templateName + ".template"
	out := mustache.RenderFile(filename, viewData.Context, getHelpers())

	return out
}