softmoth / raku-Template-Mustache

Raku library for the Mustache template format
https://modules.raku.org/dist/Template::Mustache:cpan:SOFTMOTH
Artistic License 2.0
21 stars 19 forks source link

Optionally warn if template requires field missing from context #24

Closed scmorrison closed 5 years ago

scmorrison commented 5 years ago

This modification will allow for printing warning messages when a field referenced in a template is missing from context.

Template::Mustache.render(
    '{{missing_field1}} {{missing_field2}} {{missing.field}}\n',
{}, :warn);

# Field not found ❮missing_field1❯
# Field not found ❮missing_field2❯
# Field not found ❮missing.field❯

render will continue with the current behavior without the :warn flag.

softmoth commented 5 years ago

Thanks for this patch! I can see this coming in handy during development....

scmorrison commented 5 years ago

Thanks!