use v6;
use Cro::WebApp::Template::ASTBuilder;
use Cro::WebApp::Template::Parser;
use Cro::WebApp::Template::Repository;
role Cro::WebApp::TemplateString {
has $!template-repo;
submethod TWEAK {
$!template-repo = Cro::WebApp::Template::Repository.new
}
method render ($template, *%params) {
my $*TEMPLATE-REPOSITORY = $!template-repo;
my $ast = Cro::WebApp::Template::Parser.parse(
$template,
actions => Cro::WebApp::Template::ASTBuilder
).ast;
Cro::WebApp::Template::Compiled.new(
|$ast.compile,
repository => $!template-repo
).render(%params);
}
}
Last active
January 7, 2021 00:04
-
-
Save Xliff/23d83c2ddcfc69aae26f33c572caa87d to your computer and use it in GitHub Desktop.
This Role will allow you to use string literals as templates with Cro::WebApp
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment