const mixinafEfanExtra::EfanTemplateConverters

afEfanExtra::EfanTemplateConverters

(Service) - Contribute to 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 afSlim::Slim
using afEfanExtra::EfanTemplateConverters

...

@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 efan templates.

@uses Mapped config of [Str:|File->Str|] - file ext to func that converts the file to an efan str

canConvert

Source

abstract Bool canConvert(File file)

Returns true if the given file can be converted / has a known extension

convertTemplate

Source

abstract Str convertTemplate(File templateFile)

Converts the given File in to an efan template Str.

extensions

Source

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"]