const classafEfan::EfanCompiler

sys::Obj
  afEfan::EfanCompiler

Compiles efan templates into Fantom types. Compiled types extend EfanRenderer and have the standard serialisation ctor:

new make(|This|? f) { f?.call(this) }

This ensures you can create an instance of the render just by calling make(). Call render() to render the efan template into a Str.

template := ...
efanType := EfanCompiler().compile(`index.efan`, template)
htmlStr  := efanType.make.render(...)
compile

Source

Type compile(Uri srcLocation, Str efanTemplate, Type? ctxType := null)

Standard compilation usage; the returned type extends EfanRenderer. Compiles a new renderer from the given efanTemplate.

This method compiles a new Fantom Type so use judiciously to avoid memory leaks. srcLocation is only used for Err msgs.

compileWithHelpers

Source

Type compileWithHelpers(Uri srcLocation, Str efanTemplate, Type? ctxType := null, Type[] viewHelpers := Type[])Type#.emptyList()

Intermediate compilation usage; the returned type extends EfanRenderer. The compiled renderer extends the given view helper mixins.

This method compiles a new Fantom Type so use judiciously to avoid memory leaks. srcLocation is only used for Err msgs.

compileWithModel

Source

Type compileWithModel(Uri srcLocation, Str efanTemplate, Type? ctxType, PlasticClassModel model)

Advanced compiler usage; the returned type extends EfanRenderer. The efan render methods are added to the given afPlastic model.

This method compiles a new Fantom Type so use judiciously to avoid memory leaks. srcLocation is only used for Err msgs.

ctxVarName

Source

const Str ctxVarName := "ctx"

The name given to the ctx variable in the render method.

make

Source

new make(|This? in := null)

Create an EfanCompiler.

srcCodePadding

Source

const Int srcCodePadding := 5

When generating code snippets to report compilation Errs, this is the number of lines of src code the erroneous line should be padded with.