const mixinafEfanXtra::EfanTemplateConverters
afEfanXtra::EfanTemplateConverters
(Service) - Contribute functions that convert files to efan templates.
Some templates, such as afSlim, need to be pre-processed / converted to efan notation before they can be compiled into components. Do this by contributing file converting functions to EfanTemplateConverters. The functions are keyed off a file extension.
Example, to use afSlim templates add the following to your AppModule:
using afIoc
using afSlim
using afEfanXtra
class AppModule {
@Contribute { serviceType=EfanTemplateConverters# }
static Void contributeSlimTemplates(MappedConfig config, Slim slim) {
config["slim"] = |File file -> Str| { slim.parseFromFile(file) }
}
}
That will convert all files with a .slim extension to an efan template.
@uses Mapped config 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"]