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
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.
srcLocationis only used for Err msgs.- compileWithHelpers
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.
srcLocationis only used for Err msgs.- compileWithModel
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.
srcLocationis only used for Err msgs.- ctxVarName
const Str ctxVarName := "ctx"The name given to the
ctxvariable in the render method.- make
new make(|This? in := null)Create an
EfanCompiler.- srcCodePadding
const Int srcCodePadding := 5When generating code snippets to report compilation Errs, this is the number of lines of src code the erroneous line should be padded with.