NAME
Text::Nunjucks::Compiler - 1:1 port of Nunjucks src/compiler.js -- emits Perl source
VERSION
version 0.001
DESCRIPTION
Engine-internal: this module is a stage of the template pipeline, used by Text::Nunjucks::Environment, and not an interface for applications.
A 1:1 port of Nunjucks src/compiler.js. Unlike every other ported module, this one emits Perl source (upstream emits JavaScript), keeping upstream's CPS shape (ADR 0003): every continuation but the callbacks of a block call is wrapped in a call that holds the render's context, and a few port-only statements keep a render from leaking (ADR 0021), so the text is not literally upstream's. Text::Nunjucks::Compiler->compile($src, $async_filters, $extensions, $name, $opts) returns a string that, when evaled, yields a hashref { root => \&root, b_<name> => \&b_<name>, ... }. The class that walks the AST and emits the code is Text::Nunjucks::Compiler::Compiler (reachable as Text::Nunjucks::Compiler->compiler_class, mirroring upstream's exported Compiler).
The emitted code calls into $runtime (Text::Nunjucks::Runtime, class-method API) for every operator and value operation, $env / $context for the environment surface (implemented by Text::Nunjucks::Environment), and uses $frame / $cb per the callback protocol.
SUPPORT
Issues
Please report bugs and feature requests at https://github.com/Getty/p5-text-nunjucks/issues.
CONTRIBUTING
Contributions are welcome! Please fork the repository and submit a pull request.
AUTHOR
Torsten Raudssus <getty@cpan.org>
COPYRIGHT AND LICENSE
This software is copyright (c) 2026 by Torsten Raudssus <torsten@raudssus.de> https://raudssus.de/.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.