const classafEfan::EfanTemplateMeta
sys::Obj afEfan::EfanTemplateMeta
Meta data about an efan template.
Generated by the efan compiler.
- ctxName
const Str? ctxName
The name of the
ctx
variable the template was compiled with. Returnsnull
if a ctx variable was not used.- ctxType
const Type? ctxType
The
ctx
type the template was compiled against. Returnsnull
if a ctx variable was not used.- instance
Obj instance(Obj[]? ctorParams := null)
Creates an efan template instance. If the template
type
is const, and noctorParams
are specified then the instance is cached for re-use.- render
Str render(Obj? ctx, |Obj?? bodyFunc := null)
The main render method.
ctx
must be provided. This prevents you from accidently passing inbodyFunc
as thectx
. Example:layout.render() { ... }
// --> WRONG!layout.render(null) { ... }// --> CORRECT!The
bodyFunc
is executed whenrenderBody()
is called. Use it when enclosing content in Layout templates. Example:... <%= ctx.layout.render(ctx.layoutCtx) { %> ... my body content ... <% } %> ...
The signature for
bodyFunc
is actually|->|? bodyFunc
- see source for an explanation of why|Obj?|?
is used.- renderBody
virtual Str renderBody()
Renders the body of the enclosing efan template. Should only be called from within templates.
Example, a simple
layout.html
may be defined as:<html> <head> <title><%= ctx.pageTitle %> </html> <body> <%= renderBody() %> </html>
- renderFrom
Str renderFrom(Obj instance, Obj? ctx, |Obj?? bodyFunc := null)
Renders the given template instance, as oppose to the given
- templateId
const Str templateId
A unique ID for the template. Defaults to the fully qualified type name.
- templateLoc
const Uri templateLoc
Where the template originated from. Example,
file://layout.efan
.- templateSrc
const Str templateSrc
The original efan template source string.
- type
const Type type
The
Type
of the compiled efan template.- typeSrc
const Str typeSrc
The generated fantom code of the efan template (for the inquisitive).