html

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Nov 11, 2016 License: MIT Imports: 9 Imported by: 17

README

Folder information

This folder contains the buit'n and the default html/template cross-framework template engine support.

Documentation

Index

Constants

View Source
const (
	// NoLayout to disable layout for a particular template file
	NoLayout = "@.|.@no_layout@.|.@"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Left        string
	Right       string
	Layout      string
	Funcs       map[string]interface{}
	LayoutFuncs map[string]interface{}
}

Config for html template engine

func DefaultConfig

func DefaultConfig() Config

DefaultConfig returns the default configs for the html template engine

type Engine

type Engine struct {
	Config     Config
	Middleware func(name string, contents string) (string, error)
	Templates  *template.Template
	// contains filtered or unexported fields
}

Engine the html/template engine

func New

func New(cfg ...Config) *Engine

New creates and returns the HTMLTemplate template engine

func (*Engine) ExecuteRaw

func (s *Engine) ExecuteRaw(src string, wr io.Writer, binding interface{}) (err error)

ExecuteRaw receives, parse and executes raw source template contents it's super-simple function without options and funcs, it's not used widely implements the EngineRawExecutor interface

func (*Engine) ExecuteWriter

func (s *Engine) ExecuteWriter(out io.Writer, name string, binding interface{}, options ...map[string]interface{}) error

ExecuteWriter executes a templates and write its results to the out writer

func (*Engine) Funcs

func (s *Engine) Funcs() map[string]interface{}

Funcs should returns the helper funcs

func (*Engine) LoadAssets

func (s *Engine) LoadAssets(virtualDirectory string, virtualExtension string, assetFn func(name string) ([]byte, error), namesFn func() []string) error

LoadAssets loads the templates by binary

func (*Engine) LoadDirectory

func (s *Engine) LoadDirectory(dir string, extension string) error

LoadDirectory builds the templates

Jump to

Keyboard shortcuts

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