fromString method
Load a template from a source string without using loader.
Implementation
Template fromString(
String source, {
String? path,
Map<String, Object?>? globals,
}) {
if (globals == null) {
globals = HashMap<String, Object?>.of(this.globals);
} else {
globals = HashMap<String, Object?>.of(this.globals)..addAll(globals);
}
var body = parse(source, path: path);
for (var modifier in modifiers) {
body = modifier(body);
}
if (optimize) {
body = body.accept(const Optimizer(), Context(this));
}
return Template.fromNode(
this,
path: path,
globals: globals,
body: body.accept(RuntimeCompiler(), null),
);
}