const classafEfan::EfanTemplateMeta

sys::Obj
  afEfan::EfanTemplateMeta

Meta data about an efan template.

Generated by the efan compiler.

ctxName

Source

const Str? ctxName

The name of the ctx variable the template was compiled with. Returns null if a ctx variable was not used.

ctxType

Source

const Type? ctxType

The ctx type the template was compiled against. Returns null if a ctx variable was not used.

instance

Source

Obj instance(Obj[]? ctorParams := null)

Creates an efan template instance. If the template type is const, and no ctorParams are specified then the instance is cached for re-use.

render

Source

Str render(Obj? ctx, |Obj?? bodyFunc := null)

The main render method.

ctx must be provided. This prevents you from accidently passing in bodyFunc as the ctx. Example:

layout.render() { ... }      // --> WRONG!
layout.render(null) { ... }  // --> CORRECT!

The bodyFunc is executed when renderBody() 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

Source

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

Source

Str renderFrom(Obj instance, Obj? ctx, |Obj?? bodyFunc := null)

Renders the given template instance, as oppose to the given

templateId

Source

const Str templateId

A unique ID for the template. Defaults to the fully qualified type name.

templateLoc

Source

const Uri templateLoc

Where the template originated from. Example, file://layout.efan.

templateSrc

Source

const Str templateSrc

The original efan template source string.

type

Source

const Type type

The Type of the compiled efan template.

typeSrc

Source

const Str typeSrc

The generated fantom code of the efan template (for the inquisitive).