Documentation
¶
Index ¶
- Constants
- type BuildOptions
- type CSS
- type CSSEnvStringer
- type CSSStringer
- type CompilerError
- type Converter
- type Declarations
- type EnvStringer
- type Format
- type FormatFS
- type HTML
- type HTMLEnvStringer
- type HTMLStringer
- type JS
- type JSEnvStringer
- type JSON
- type JSONEnvStringer
- type JSONStringer
- type JSStringer
- type MapFS
- type Markdown
- type MarkdownEnvStringer
- type MarkdownStringer
- type RunOptions
- type Template
Constants ¶
const ( FormatText = ast.FormatText FormatHTML = ast.FormatHTML FormatCSS = ast.FormatCSS FormatJS = ast.FormatJS FormatJSON = ast.FormatJSON FormatMarkdown = ast.FormatMarkdown )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BuildOptions ¶ added in v0.31.0
type BuildOptions struct {
DisallowGoStmt bool
TreeTransformer func(*ast.Tree) error // if not nil transforms tree after parsing.
// MarkdownConverter converts a Markdown source code to HTML.
MarkdownConverter Converter
// Globals declares constants, types, variables and functions that are
// accessible from the code in the template.
Globals Declarations
// Packages is a PackageLoader that makes precompiled packages available
// in the template through the 'import' statement.
//
// Note that an import statement refers to a precompiled package read from
// Packages if its path has no extension.
//
// {% import "my/package" %} Import a precompiled package.
// {% import "my/file.html %} Import a template file.
//
Packages scriggo.PackageLoader
}
type CSSEnvStringer ¶
CSSEnvStringer is like CSSStringer where the CSS method takes a runtime.Env parameter.
type CSSStringer ¶
type CSSStringer interface {
CSS() CSS
}
CSSStringer is implemented by values that are not escaped in CSS context.
type CompilerError ¶
CompilerError represents an error returned by the compiler.
type EnvStringer ¶
EnvStringer is like fmt.Stringer where the String method takes a runtime.Env parameter.
type FormatFS ¶ added in v0.33.0
FormatFS is the interface implemented by a file system that can determine the file format from a path name.
type HTML ¶
type HTML string // the html type in templates.
Format types.
func HTMLEscape ¶ added in v0.23.0
HTMLEscape escapes s, replacing the characters <, >, &, " and ' and returns the escaped string as HTML type.
Use HTMLEscape to put a trusted or untrusted string into an HTML element content or in a quoted attribute value. But don't use it with complex attributes like href, src, style, or any of the event handlers like onmouseover.
type HTMLEnvStringer ¶
HTMLEnvStringer is like HTMLStringer where the HTML method takes a runtime.Env parameter.
type HTMLStringer ¶
type HTMLStringer interface {
HTML() HTML
}
HTMLStringer is implemented by values that are not escaped in HTML context.
type JSEnvStringer ¶ added in v0.30.0
JSEnvStringer is like JSStringer where the JS method takes a runtime.Env parameter.
type JSONEnvStringer ¶ added in v0.16.0
JSONEnvStringer is like JSONStringer where the JSON method takes a runtime.Env parameter.
type JSONStringer ¶ added in v0.16.0
type JSONStringer interface {
JSON() JSON
}
JSONStringer is implemented by values that are not escaped in JSON context.
type JSStringer ¶ added in v0.30.0
type JSStringer interface {
JS() JS
}
JSStringer is implemented by values that are not escaped in JavaScript context.
type Markdown ¶ added in v0.31.0
type Markdown string // the markdown type in templates.
Format types.
type MarkdownEnvStringer ¶ added in v0.31.0
MarkdownEnvStringer is like MarkdownStringer where the Markdown method takes a runtime.Env parameter.
type MarkdownStringer ¶ added in v0.31.0
type MarkdownStringer interface {
Markdown() Markdown
}
MarkdownStringer is implemented by values that are not escaped in Markdown context.
type RunOptions ¶ added in v0.31.0
type Template ¶
type Template struct {
// contains filtered or unexported fields
}
func Build ¶ added in v0.31.0
Build builds the named template file rooted at the given file system.
If fsys implements FormatFS, the file format is read from its Format method, otherwise it depends on the file name extension
HTML : .html CSS : .css JavaScript : .js JSON : .json Markdown : .md .mkd .mkdn .mdown .markdown Text : all other extensions
func (*Template) Disassemble ¶
Disassemble disassembles a template and returns its assembly code.
n determines the maximum length, in runes, of a disassembled text:
n > 0: at most n runes; leading and trailing white space are removed n == 0: no text n < 0: all text
func (*Template) MustRun ¶ added in v0.31.0
func (t *Template) MustRun(out io.Writer, vars map[string]interface{}, options *RunOptions)
MustRun is like Run but panics if the execution fails.