Classic
NAME
Template::Classic - Templates with arbitrary Raku code inside them
SYNOPSIS
use Template::Classic;
my &render-list := template :($title, @items), q:to/HTML/;
<h1><%= $title %></h1>
<ul>
<% for @items -> $item { %>
<li><%= $item %></li>
<% } %>
</ul>
HTML
print render-list(ļ½¢Shopping listļ½£,
[ļ½¢Cheeseļ½£, ļ½¢Baconļ½£]);
DESCRIPTION
Templates are strings with <% %>
-delimited snippets of Raku code inside
them. Embedded Raku code can use take to emit strings into the rendered
template. In addition, <%= %>
delimiters can be used to emit the result of
evaluating an expression. This value is converted to a string by calling its
.Str method and special HTML characters are escaped.
BUGS
Due to a bug in Rakudo this module compiles the template only on the first call to the template, rather than immediately when template is called. This will be fixed in a future version and must not be relied upon.
}