const mixinafEfanXtra::TemplateConverters
afEfanXtra::TemplateConverters
(Service) - Contribute functions to convert files into efan templates.
Some templates, such as Slim templates, need to be pre-processed / converted to efan notation before they can be compiled. To do this, a conversion function is looked up via the file extension. If no function is found, the file is assumed to be an efan template and read in as a simple string.
For example, to use Slim templates add the following to your AppModule:
using afIoc
using afSlim
using afEfanXtra
class AppModule {
@Contribute { serviceType=TemplateConverters# }
static Void contributeSlimTemplates(Configuration config, Slim slim) {
config["slim"] = |File file -> Str| { slim.parseFromFile(file) }
}
}
This will convert all files with a .slim extension to an efan template.
By default, a function is supplied that converts all files with a .fandoc extension into HTML.
@uses Configuration of Str : |File->Str| - file ext to func that converts the file to an efan template
- canConvert
abstract Bool canConvert(File file)Returns
trueif the given file can be converted / has a known extension.- convertTemplate
abstract Str convertTemplate(File templateFile)Converts the given
Fileto an efan template Str.- extensions
abstract Str[] extensions()Return a list of (lowercase) file extensions that denote which files can be converted to efan templates.
Note the extensions are not prefixed with a dot, e.g.
["efan", "slim"]