Documentation ¶
Index ¶
- Constants
- Variables
- func AddJetRuntimeVars(ctx *context.Context, jetVarMap JetRuntimeVars)
- type AceEngine
- type BlocksEngine
- func (s *BlocksEngine) AddFunc(funcName string, funcBody interface{})
- func (s *BlocksEngine) AddLayoutFunc(funcName string, funcBody interface{}) *BlocksEngine
- func (s *BlocksEngine) ExecuteWriter(w io.Writer, tmplName, layoutName string, data interface{}) error
- func (s *BlocksEngine) Ext() string
- func (s *BlocksEngine) Layout(layoutName string) *BlocksEngine
- func (s *BlocksEngine) LayoutDir(relToDirLayoutDir string) *BlocksEngine
- func (s *BlocksEngine) Load() error
- func (s *BlocksEngine) Name() string
- func (s *BlocksEngine) Reload(b bool) *BlocksEngine
- func (s *BlocksEngine) RootDir(root string) *BlocksEngine
- type DjangoEngine
- func (s *DjangoEngine) AddFilter(filterName string, filterBody FilterFunction) *DjangoEngine
- func (s *DjangoEngine) AddFunc(funcName string, funcBody interface{})
- func (s *DjangoEngine) ExecuteWriter(w io.Writer, filename string, _ string, bindingData interface{}) error
- func (s *DjangoEngine) Ext() string
- func (s *DjangoEngine) Load() error
- func (s *DjangoEngine) Name() string
- func (s *DjangoEngine) ParseTemplate(name string, contents []byte) error
- func (s *DjangoEngine) RegisterFilter(filterName string, filterBody FilterFunction) *DjangoEngine
- func (s *DjangoEngine) RegisterTag(tagName string, fn TagParser) error
- func (s *DjangoEngine) Reload(developmentMode bool) *DjangoEngine
- func (s *DjangoEngine) RootDir(root string) *DjangoEngine
- type Engine
- type EngineFuncer
- type ErrNotExist
- type Error
- type FilterFunction
- type HTMLEngine
- func (s *HTMLEngine) AddFunc(funcName string, funcBody interface{})
- func (s *HTMLEngine) AddLayoutFunc(funcName string, funcBody interface{}) *HTMLEngine
- func (s *HTMLEngine) Delims(left, right string) *HTMLEngine
- func (s *HTMLEngine) ExecuteWriter(w io.Writer, name string, layout string, bindingData interface{}) error
- func (s *HTMLEngine) Ext() string
- func (s *HTMLEngine) FS(dirOrFS interface{}) *HTMLEngine
- func (s *HTMLEngine) Funcs(funcMap template.FuncMap) *HTMLEngine
- func (s *HTMLEngine) Layout(layoutFile string) *HTMLEngine
- func (s *HTMLEngine) Load() error
- func (s *HTMLEngine) Name() string
- func (s *HTMLEngine) Option(opt ...string) *HTMLEngine
- func (s *HTMLEngine) ParseTemplate(name string, contents []byte, funcs template.FuncMap) (err error)
- func (s *HTMLEngine) Reload(developmentMode bool) *HTMLEngine
- func (s *HTMLEngine) RootDir(root string) *HTMLEngine
- func (s *HTMLEngine) SetFuncs(funcMap template.FuncMap) *HTMLEngine
- type HandlebarsEngine
- func (s *HandlebarsEngine) AddFunc(funcName string, funcBody interface{})
- func (s *HandlebarsEngine) AddGlobalFunc(funcName string, funcBody interface{})
- func (s *HandlebarsEngine) ExecuteWriter(w io.Writer, filename string, layout string, bindingData interface{}) error
- func (s *HandlebarsEngine) Ext() string
- func (s *HandlebarsEngine) Layout(layoutFile string) *HandlebarsEngine
- func (s *HandlebarsEngine) Load() error
- func (s *HandlebarsEngine) Name() string
- func (s *HandlebarsEngine) ParseTemplate(name string, contents string, funcs template.FuncMap) error
- func (s *HandlebarsEngine) Reload(developmentMode bool) *HandlebarsEngine
- func (s *HandlebarsEngine) RootDir(root string) *HandlebarsEngine
- type INodeTag
- type JetArguments
- type JetEngine
- func (s *JetEngine) AddFunc(funcName string, funcBody interface{})
- func (s *JetEngine) AddRuntimeVars(ctx *context.Context, vars JetRuntimeVars)
- func (s *JetEngine) AddVar(key string, value interface{})
- func (s *JetEngine) Delims(left, right string) *JetEngine
- func (s *JetEngine) ExecuteWriter(w io.Writer, filename string, layout string, bindingData interface{}) error
- func (s *JetEngine) Ext() string
- func (s *JetEngine) Load() error
- func (s *JetEngine) Name() string
- func (s *JetEngine) ParseTemplate(name string, contents string) error
- func (s *JetEngine) Reload(developmentMode bool) *JetEngine
- func (s *JetEngine) RootDir(root string) *JetEngine
- func (s *JetEngine) SetLoader(loader jet.Loader) *JetEngine
- func (s *JetEngine) String() string
- type JetRuntime
- type JetRuntimeVars
- type Parser
- type TagParser
- type Token
- type Value
- type View
- func (v *View) AddFunc(funcName string, funcBody interface{})
- func (v *View) ExecuteWriter(w io.Writer, filename string, layout string, bindingData interface{}) error
- func (v *View) Funcs(m template.FuncMap) *View
- func (v *View) Load() error
- func (v *View) Register(e Engine)
- func (v *View) Registered() bool
Constants ¶
const JetRuntimeVarsContextKey = "iris.jetvarmap"
JetRuntimeVarsContextKey is the Iris Context key to keep any custom jet runtime variables. See `AddJetRuntimeVars` package-level function and `JetEngine.AddRuntimeVars` method.
const NoLayout = "iris.nolayout"
NoLayout disables the configuration's layout for a specific execution.
Variables ¶
var AsSafeValue = pongo2.AsSafeValue
AsSafeValue works like AsValue, but does not apply the 'escape' filter. Shortcut for `pongo2.AsSafeValue`.
var AsValue = pongo2.AsValue
AsValue converts any given value to a pongo2.Value Usually being used within own functions passed to a template through a Context or within filter functions.
Example:
AsValue("my string")
Shortcut for `pongo2.AsValue`.
Functions ¶
func AddJetRuntimeVars ¶
func AddJetRuntimeVars(ctx *context.Context, jetVarMap JetRuntimeVars)
AddJetRuntimeVars sets or inserts runtime jet variables through the Iris Context. This gives the ability to add runtime variables from different handlers in the request chain, something that the jet template parser does not offer at all.
Usage: view.AddJetRuntimeVars(ctx, view.JetRuntimeVars{...}). See `JetEngine.AddRuntimeVars` too.
Types ¶
type AceEngine ¶ added in v12.2.0
type AceEngine struct { *HTMLEngine // contains filtered or unexported fields }
AceEngine represents the Ace view engine. See the `Ace` package-level function for more.
func Ace ¶ added in v12.2.0
Ace returns a new Ace view engine. It shares the same exactly logic with the html view engine, it uses the same exactly configuration. The given "extension" MUST begin with a dot. Ace minifies the response automatically unless SetIndent() method is set.
Read more about the Ace Go Parser: https://github.com/yosssi/ace
Usage: Ace("./views", ".ace") or Ace(iris.Dir("./views"), ".ace") or Ace(embed.FS, ".ace") or Ace(AssetFile(), ".ace") for embedded data.
type BlocksEngine ¶ added in v12.2.0
BlocksEngine is an Iris view engine adapter for the blocks view engine. The blocks engine is based on the html/template standard Go package.
To initialize a fresh one use the `Blocks` function. To wrap an existing one use the `WrapBlocks` function.
It contains the following four default template functions: - url "routename" parameters... - urlpath "routename" parameters... - tr "language" "key" arguments... - partial "template_name" data
Read more at: https://github.com/kataras/blocks.
func Blocks ¶ added in v12.2.0
func Blocks(fs interface{}, extension string) *BlocksEngine
Blocks returns a new blocks view engine. The given "extension" MUST begin with a dot.
See `WrapBlocks` package-level function too.
Usage: Blocks("./views", ".html") or Blocks(iris.Dir("./views"), ".html") or Blocks(embed.FS, ".html") or Blocks(AssetFile(), ".html") for embedded data.
func WrapBlocks ¶ added in v12.2.0
func WrapBlocks(v *blocks.Blocks) *BlocksEngine
WrapBlocks wraps an initialized blocks engine and returns its Iris adapter. See `Blocks` package-level function too.
func (*BlocksEngine) AddFunc ¶ added in v12.2.0
func (s *BlocksEngine) AddFunc(funcName string, funcBody interface{})
AddFunc implements the `EngineFuncer` which is being used by the framework to add template functions like: - url func(routeName string, args ...string) string - urlpath func(routeName string, args ...string) string - tr func(lang, key string, args ...interface{}) string
func (*BlocksEngine) AddLayoutFunc ¶ added in v12.2.0
func (s *BlocksEngine) AddLayoutFunc(funcName string, funcBody interface{}) *BlocksEngine
AddLayoutFunc adds a template function for templates that are marked as layouts.
func (*BlocksEngine) ExecuteWriter ¶ added in v12.2.0
func (s *BlocksEngine) ExecuteWriter(w io.Writer, tmplName, layoutName string, data interface{}) error
ExecuteWriter renders a template on "w".
func (*BlocksEngine) Ext ¶ added in v12.2.0
func (s *BlocksEngine) Ext() string
Ext returns empty ext as this template engine supports template blocks without file suffix. Note that, if more than one view engine is registered to a single Iris application then, this Blocks engine should be the last entry one.
func (*BlocksEngine) Layout ¶ added in v12.2.0
func (s *BlocksEngine) Layout(layoutName string) *BlocksEngine
Layout sets the default layout which inside should use the {{ template "content" . }} to render the main template.
Example for ./views/layouts/main.html: Blocks("./views", ".html").Layout("layouts/main")
func (*BlocksEngine) LayoutDir ¶ added in v12.2.0
func (s *BlocksEngine) LayoutDir(relToDirLayoutDir string) *BlocksEngine
LayoutDir sets a custom layouts directory, always relative to the "rootDir" one. Layouts are recognised by their prefix names. Defaults to "layouts".
func (*BlocksEngine) Load ¶ added in v12.2.0
func (s *BlocksEngine) Load() error
Load parses the files into templates.
func (*BlocksEngine) Name ¶ added in v12.2.0
func (s *BlocksEngine) Name() string
Name returns the blocks engine's name.
func (*BlocksEngine) Reload ¶ added in v12.2.0
func (s *BlocksEngine) Reload(b bool) *BlocksEngine
Reload if called with a true parameter, each `ExecuteWriter` call will re-parse the templates. Useful when the application is at a development stage.
func (*BlocksEngine) RootDir ¶ added in v12.2.0
func (s *BlocksEngine) RootDir(root string) *BlocksEngine
RootDir sets the directory to use as the root one inside the provided File System.
type DjangoEngine ¶
type DjangoEngine struct { Set *pongo2.TemplateSet // contains filtered or unexported fields }
DjangoEngine contains the django view engine structure.
func Django ¶
func Django(fs interface{}, extension string) *DjangoEngine
Django creates and returns a new django view engine. The given "extension" MUST begin with a dot.
Usage: Django("./views", ".html") or Django(iris.Dir("./views"), ".html") or Django(embed.FS, ".html") or Django(AssetFile(), ".html") for embedded data.
func (*DjangoEngine) AddFilter ¶
func (s *DjangoEngine) AddFilter(filterName string, filterBody FilterFunction) *DjangoEngine
AddFilter registers a new filter. If there's already a filter with the same name, RegisterFilter will panic. You usually want to call this function in the filter's init() function: http://golang.org/doc/effective_go.html#init
Same as `RegisterFilter`.
func (*DjangoEngine) AddFunc ¶
func (s *DjangoEngine) AddFunc(funcName string, funcBody interface{})
AddFunc adds the function to the template's Globals. It is legal to overwrite elements of the default actions: - url func(routeName string, args ...string) string - urlpath func(routeName string, args ...string) string - render func(fullPartialName string) (template.HTML, error).
func (*DjangoEngine) ExecuteWriter ¶
func (s *DjangoEngine) ExecuteWriter(w io.Writer, filename string, _ string, bindingData interface{}) error
ExecuteWriter executes a templates and write its results to the w writer layout here is useless.
func (*DjangoEngine) Ext ¶
func (s *DjangoEngine) Ext() string
Ext returns the file extension which this view engine is responsible to render. If the filename extension on ExecuteWriter is empty then this is appended.
func (*DjangoEngine) Load ¶
func (s *DjangoEngine) Load() error
Load parses the templates to the engine. It is responsible to add the necessary global functions.
Returns an error if something bad happens, user is responsible to catch it.
func (*DjangoEngine) Name ¶ added in v12.2.0
func (s *DjangoEngine) Name() string
Name returns the django engine's name.
func (*DjangoEngine) ParseTemplate ¶ added in v12.2.0
func (s *DjangoEngine) ParseTemplate(name string, contents []byte) error
ParseTemplate adds a custom template from text. This parser does not support funcs per template. Use the `AddFunc` instead.
func (*DjangoEngine) RegisterFilter ¶
func (s *DjangoEngine) RegisterFilter(filterName string, filterBody FilterFunction) *DjangoEngine
RegisterFilter registers a new filter. If there's already a filter with the same name, RegisterFilter will panic. You usually want to call this function in the filter's init() function: http://golang.org/doc/effective_go.html#init
See http://www.florian-schlachter.de/post/pongo2/ for more about writing filters and tags.
func (*DjangoEngine) RegisterTag ¶
func (s *DjangoEngine) RegisterTag(tagName string, fn TagParser) error
RegisterTag registers a new tag. You usually want to call this function in the tag's init() function: http://golang.org/doc/effective_go.html#init
See http://www.florian-schlachter.de/post/pongo2/ for more about writing filters and tags.
func (*DjangoEngine) Reload ¶
func (s *DjangoEngine) Reload(developmentMode bool) *DjangoEngine
Reload if set to true the templates are reloading on each render, use it when you're in development and you're boring of restarting the whole app when you edit a template file.
Note that if `true` is passed then only one `View -> ExecuteWriter` will be render each time, no concurrent access across clients, use it only on development status. It's good to be used side by side with the https://github.com/kataras/rizla reloader for go source files.
func (*DjangoEngine) RootDir ¶ added in v12.2.0
func (s *DjangoEngine) RootDir(root string) *DjangoEngine
RootDir sets the directory to be used as a starting point to load templates from the provided file system.
type Engine ¶
type Engine = context.ViewEngine
Engine is the interface for a compatible Iris view engine. It's an alias of context.ViewEngine.
type EngineFuncer ¶
type EngineFuncer = context.ViewEngineFuncer
EngineFuncer is the interface for a compatible Iris view engine which accepts builtin framework functions such as url, urlpath and tr. It's an alias of context.ViewEngineFuncer.
type ErrNotExist ¶ added in v12.2.0
type ErrNotExist = context.ErrViewNotExist
ErrNotExist reports whether a template was not found in the parsed templates tree.
type FilterFunction ¶
type FilterFunction = pongo2.FilterFunction
FilterFunction type alias for pongo2.FilterFunction
type HTMLEngine ¶
HTMLEngine contains the html view engine structure.
func HTML ¶
func HTML(dirOrFS interface{}, extension string) *HTMLEngine
HTML creates and returns a new html view engine. The html engine used like the "html/template" standard go package but with a lot of extra features. The given "extension" MUST begin with a dot.
Usage: HTML("./views", ".html") or HTML(iris.Dir("./views"), ".html") or HTML(embed.FS, ".html") or HTML(AssetFile(), ".html") for embedded data or HTML("","").ParseTemplate("hello", `[]byte("hello {{.Name}}")`, nil) for custom template parsing only.
func Pug ¶
func Pug(fs interface{}, extension string) *HTMLEngine
Pug (or Jade) returns a new pug view engine. It shares the same exactly logic with the html view engine, it uses the same exactly configuration. The given "extension" MUST begin with a dot.
Read more about the Jade Go Parser: https://github.com/Joker/jade
Usage: Pug("./views", ".pug") or Pug(iris.Dir("./views"), ".pug") or Pug(embed.FS, ".pug") or Pug(AssetFile(), ".pug") for embedded data.
Examples: https://github.com/kataras/iris/tree/main/_examples/view/template_pug_0 https://github.com/kataras/iris/tree/main/_examples/view/template_pug_1 https://github.com/kataras/iris/tree/main/_examples/view/template_pug_2 https://github.com/kataras/iris/tree/main/_examples/view/template_pug_3
func (*HTMLEngine) AddFunc ¶
func (s *HTMLEngine) AddFunc(funcName string, funcBody interface{})
AddFunc adds the function to the template's function map. It is legal to overwrite elements of the default actions: - url func(routeName string, args ...string) string - urlpath func(routeName string, args ...string) string - render func(fullPartialName string) (template.HTML, error). - tr func(lang, key string, args ...interface{}) string
func (*HTMLEngine) AddLayoutFunc ¶
func (s *HTMLEngine) AddLayoutFunc(funcName string, funcBody interface{}) *HTMLEngine
AddLayoutFunc adds the function to the template's layout-only function map. It is legal to overwrite elements of the default layout actions: - yield func() (template.HTML, error) - current func() (string, error) - partial func(partialName string) (template.HTML, error) - partial_r func(partialName string) (template.HTML, error) - render func(fullPartialName string) (template.HTML, error).
func (*HTMLEngine) Delims ¶
func (s *HTMLEngine) Delims(left, right string) *HTMLEngine
Delims sets the action delimiters to the specified strings, to be used in templates. An empty delimiter stands for the corresponding default: {{ or }}.
func (*HTMLEngine) ExecuteWriter ¶
func (s *HTMLEngine) ExecuteWriter(w io.Writer, name string, layout string, bindingData interface{}) error
ExecuteWriter executes a template and writes its result to the w writer.
func (*HTMLEngine) Ext ¶
func (s *HTMLEngine) Ext() string
Ext returns the file extension which this view engine is responsible to render. If the filename extension on ExecuteWriter is empty then this is appended.
func (*HTMLEngine) FS ¶ added in v12.2.9
func (s *HTMLEngine) FS(dirOrFS interface{}) *HTMLEngine
FS change templates DIR
func (*HTMLEngine) Funcs ¶ added in v12.2.0
func (s *HTMLEngine) Funcs(funcMap template.FuncMap) *HTMLEngine
Funcs adds the elements of the argument map to the template's function map. It is legal to overwrite elements of the map. The return value is the template, so calls can be chained.
func (*HTMLEngine) Layout ¶
func (s *HTMLEngine) Layout(layoutFile string) *HTMLEngine
Layout sets the layout template file which inside should use the {{ yield . }} func to yield the main template file and optionally {{partial/partial_r/render . }} to render other template files like headers and footers
The 'tmplLayoutFile' is a relative path of the templates base directory, for the template file with its extension.
Example: HTML("./templates", ".html").Layout("layouts/mainLayout.html")
// mainLayout.html is inside: "./templates/layouts/".
Note: Layout can be changed for a specific call action with the option: "layout" on the iris' context.Render function.
func (*HTMLEngine) Load ¶
func (s *HTMLEngine) Load() error
Load parses the templates to the engine. It's also responsible to add the necessary global functions.
Returns an error if something bad happens, caller is responsible to handle that.
func (*HTMLEngine) Name ¶ added in v12.2.0
func (s *HTMLEngine) Name() string
Name returns the engine's name.
func (*HTMLEngine) Option ¶
func (s *HTMLEngine) Option(opt ...string) *HTMLEngine
Option sets options for the template. Options are described by strings, either a simple string or "key=value". There can be at most one equals sign in an option string. If the option string is unrecognized or otherwise invalid, Option panics.
Known options:
missingkey: Control the behavior during execution if a map is indexed with a key that is not present in the map.
"missingkey=default" or "missingkey=invalid" The default behavior: Do nothing and continue execution. If printed, the result of the index operation is the string "<no value>". "missingkey=zero" The operation returns the zero value for the map type's element. "missingkey=error" Execution stops immediately with an error.
func (*HTMLEngine) ParseTemplate ¶ added in v12.2.0
func (s *HTMLEngine) ParseTemplate(name string, contents []byte, funcs template.FuncMap) (err error)
ParseTemplate adds a custom template to the root template.
func (*HTMLEngine) Reload ¶
func (s *HTMLEngine) Reload(developmentMode bool) *HTMLEngine
Reload if set to true the templates are reloading on each render, use it when you're in development and you're boring of restarting the whole app when you edit a template file.
Note that if `true` is passed then only one `View -> ExecuteWriter` will be render each time, no concurrent access across clients, use it only on development status. It's good to be used side by side with the https://github.com/kataras/rizla reloader for go source files.
func (*HTMLEngine) RootDir ¶ added in v12.2.0
func (s *HTMLEngine) RootDir(root string) *HTMLEngine
RootDir sets the directory to be used as a starting point to load templates from the provided file system.
func (*HTMLEngine) SetFuncs ¶ added in v12.2.0
func (s *HTMLEngine) SetFuncs(funcMap template.FuncMap) *HTMLEngine
SetFuncs overrides the template funcs with the given "funcMap".
type HandlebarsEngine ¶
type HandlebarsEngine struct {
// contains filtered or unexported fields
}
HandlebarsEngine contains the handlebars view engine structure.
func Handlebars ¶
func Handlebars(fs interface{}, extension string) *HandlebarsEngine
Handlebars creates and returns a new handlebars view engine. The given "extension" MUST begin with a dot.
Usage: Handlebars("./views", ".html") or Handlebars(iris.Dir("./views"), ".html") or Handlebars(embed.FS, ".html") or Handlebars(AssetFile(), ".html") for embedded data.
func (*HandlebarsEngine) AddFunc ¶
func (s *HandlebarsEngine) AddFunc(funcName string, funcBody interface{})
AddFunc adds a function to the templates. It is legal to overwrite elements of the default actions: - url func(routeName string, args ...string) string - urlpath func(routeName string, args ...string) string - render func(fullPartialName string) (raymond.HTML, error).
func (*HandlebarsEngine) AddGlobalFunc ¶ added in v12.2.0
func (s *HandlebarsEngine) AddGlobalFunc(funcName string, funcBody interface{})
AddGlobalFunc registers a global template function for all Handlebars view engines.
func (*HandlebarsEngine) ExecuteWriter ¶
func (s *HandlebarsEngine) ExecuteWriter(w io.Writer, filename string, layout string, bindingData interface{}) error
ExecuteWriter executes a template and writes its result to the w writer.
func (*HandlebarsEngine) Ext ¶
func (s *HandlebarsEngine) Ext() string
Ext returns the file extension which this view engine is responsible to render. If the filename extension on ExecuteWriter is empty then this is appended.
func (*HandlebarsEngine) Layout ¶
func (s *HandlebarsEngine) Layout(layoutFile string) *HandlebarsEngine
Layout sets the layout template file which should use the {{ yield . }} func to yield the main template file and optionally {{partial/partial_r/render . }} to render other template files like headers and footers.
func (*HandlebarsEngine) Load ¶
func (s *HandlebarsEngine) Load() error
Load parses the templates to the engine. It is responsible to add the necessary global functions.
Returns an error if something bad happens, user is responsible to catch it.
func (*HandlebarsEngine) Name ¶ added in v12.2.0
func (s *HandlebarsEngine) Name() string
Name returns the handlebars engine's name.
func (*HandlebarsEngine) ParseTemplate ¶ added in v12.2.0
func (s *HandlebarsEngine) ParseTemplate(name string, contents string, funcs template.FuncMap) error
ParseTemplate adds a custom template from text.
func (*HandlebarsEngine) Reload ¶
func (s *HandlebarsEngine) Reload(developmentMode bool) *HandlebarsEngine
Reload if set to true the templates are reloading on each render, use it when you're in development and you're boring of restarting the whole app when you edit a template file.
Note that if `true` is passed then only one `View -> ExecuteWriter` will be render each time, no concurrent access across clients, use it only on development status. It's good to be used side by side with the https://github.com/kataras/rizla reloader for go source files.
func (*HandlebarsEngine) RootDir ¶ added in v12.2.0
func (s *HandlebarsEngine) RootDir(root string) *HandlebarsEngine
RootDir sets the directory to be used as a starting point to load templates from the provided file system.
type JetArguments ¶
type JetArguments = jet.Arguments
JetArguments is a type alias of `jet.Arguments`, can be used on `AddFunc$funcBody`.
type JetEngine ¶
type JetEngine struct { // The Set is the `*jet.Set`, exported to offer any custom capabilities that jet users may want. // Available after `Load`. Set *jet.Set // contains filtered or unexported fields }
JetEngine is the jet template parser's view engine.
func Jet ¶
Jet creates and returns a new jet view engine. The given "extension" MUST begin with a dot.
Usage: Jet("./views", ".jet") or Jet(iris.Dir("./views"), ".jet") or Jet(embed.FS, ".jet") or Jet(AssetFile(), ".jet") for embedded data.
func (*JetEngine) AddRuntimeVars ¶
func (s *JetEngine) AddRuntimeVars(ctx *context.Context, vars JetRuntimeVars)
AddRuntimeVars sets or inserts runtime jet variables through the Iris Context. This gives the ability to add runtime variables from different handlers in the request chain, something that the jet template parser does not offer at all.
Usage: view.AddJetRuntimeVars(ctx, view.JetRuntimeVars{...}). See `view.AddJetRuntimeVars` if package-level access is more meanful to the code flow.
func (*JetEngine) Delims ¶
Delims sets the action delimiters to the specified strings, to be used in templates. An empty delimiter stands for the corresponding default: {{ or }}. Should act before `Load` or `iris.Application#RegisterView`.
func (*JetEngine) ExecuteWriter ¶
func (s *JetEngine) ExecuteWriter(w io.Writer, filename string, layout string, bindingData interface{}) error
ExecuteWriter should execute a template by its filename with an optional layout and bindingData.
func (*JetEngine) Ext ¶
Ext should return the final file extension which this view engine is responsible to render. If the filename extension on ExecuteWriter is empty then this is appended.
func (*JetEngine) Load ¶
Load should load the templates from a physical system directory or by an embedded one (assets/go-bindata).
func (*JetEngine) ParseTemplate ¶ added in v12.2.0
ParseTemplate accepts a name and contnets to parse and cache a template. This parser does not support funcs per template. Use the `AddFunc` instead.
func (*JetEngine) Reload ¶
Reload if setted to true the templates are reloading on each render, use it when you're in development and you're boring of restarting the whole app when you edit a template file.
Note that if `true` is passed then only one `View -> ExecuteWriter` will be render each time, not safe concurrent access across clients, use it only on development state.
func (*JetEngine) RootDir ¶ added in v12.2.0
RootDir sets the directory to be used as a starting point to load templates from the provided file system.
type JetRuntime ¶
type JetRuntime = jet.Runtime
JetRuntime is a type alias of `jet.Runtime`, can be used on RuntimeVariable input function.
type JetRuntimeVars ¶
type JetRuntimeVars = jet.VarMap
JetRuntimeVars is a type alias for `jet.VarMap`. Can be used at `AddJetRuntimeVars/JetEngine.AddRuntimeVars` to set a runtime variable ${name} to the executing template.
type TagParser ¶
type TagParser = pongo2.TagParser
TagParser the function signature of the tag's parser you will have to implement in order to create a new tag.
'doc' is providing access to the whole document while 'arguments' is providing access to the user's arguments to the tag:
{% your_tag_name some "arguments" 123 %}
start_token will be the *Token with the tag's name in it (here: your_tag_name).
Please see the Parser documentation on how to use the parser. See `RegisterTag` for more information about writing a tag as well.
type View ¶
type View struct{ Engine }
View is just a wrapper on top of the registered template engine.
func (*View) AddFunc ¶
AddFunc adds a function to all registered engines. Each template engine that supports functions has its own AddFunc too.
func (*View) ExecuteWriter ¶
func (v *View) ExecuteWriter(w io.Writer, filename string, layout string, bindingData interface{}) error
ExecuteWriter calls the correct view Engine's ExecuteWriter func
func (*View) Funcs ¶ added in v12.2.0
Funcs registers a template func map to the registered view engine(s).
func (*View) Registered ¶ added in v12.2.0
Registered reports whether an engine was registered.