Builtin

template_register

template_register(batch_name [, {template_name:str, template_content:str}])

Registers template(s) against the given batch name and returns the fragment names registered.

If no template is given, returns the fragment names already registered for the batch name.

Examples

Load and register a template from a string

template_register(
    "t1",
    dee(template_name:="test_page",
        template_content:=«
            «template "base" .»
            «define "content"»
            <h1>Test based on base</h1>
            «end»
        »
    )
)
batch_namefragment_name
t1content
t1test_page

Load and register templates from files in a subdirectory

import("os")
template_register(
    "t2",
    os.file(dirname:="templates")[not is_dir and ext=".html"](os.file_content){
        template_name:=filename, template_content:=str_rel(r:=r, sep:="\n")..s
    }
)