Skip to content

template #

fn from_strings #

fn from_strings(config TemplateConfig) !Template

from_strings creates a template from a primary string input and a map of partial names to input strings.

fn load_file #

fn load_file(config TemplateConfig) !Template

load_file loads a template from a primary input file and a map of partial names to input files.

struct Template #

struct Template {
pub:
	program          Program
	partials         []string
	partial_programs map[string]Program
}

Template is a compiled template that can be rendered with an input data model (context).

fn (Template) run #

fn (t Template) run(context DataModel) !string

run renders the template with the given DataModel context.

struct TemplateConfig #

@[params]
struct TemplateConfig {
pub:
	input    string            @[required]
	partials map[string]string = {}
}

TemplateConfig is the configuration struct for a template.