NAME
Skilletor::Render - Build an item in memory – the reference's render.ts
VERSION
version 0.008000
SYNOPSIS
use Skilletor::Render qw( build executables renders_empty templates_of );
my $output = build( $catalog_item, $source_dir, $context ); # [ [ 'skills/foo/SKILL.md', $bytes ], ... ]
my $exec = executables( $catalog_item, $source_dir ); # { 'skills/foo/run.sh' => 1 }
my $skip = renders_empty( $catalog_item, $output ); # the item does not apply here
DESCRIPTION
The reference's render.ts (spec §5): an item is built in memory. A file X.njk is rendered by Nunjucks – Text::Nunjucks, the Perl port of Nunjucks 3.2.4 the reference uses – and installed as X; every other file is copied byte for byte, so a skill that writes {{ }} itself stays intact. Each file goes to its install path – a skill's under skills/<name>/, an agent's or rule's under agents/ or rules/, wherever the item lies in its source – and a skill's files keep their source's executable bit (k99), a template passing its bit to what it renders.
A template renders as the reference's does: autoescape off, an undefined variable an error, includes, imports and macros looked up relative to the source root and confined to it (Skilletor::Render::Loader), the source read and the output written as UTF-8. A template that fails throws a Skilletor::Error::Render with the reference's message, <file>: <the Nunjucks message>.
build
build( $item, $source_dir, $context );
build( $item, $source_dir, sub { $context } );
The item's output as an ordered list of [ install path, bytes ]. The context remains the reference's RenderContext, values as Skilletor::JSON reads them: { vars, project?, scope, harness, target => { dir }, host => { name, os }, user => { name, home }, item => { name, type, source } }. A JSON null in it is the template's null, a missing field its undefined; objects keep their property order.
Alternatively, $context may be a zero-argument CODE reference. It is evaluated at the first .njk file only, including a companion template, and its returned hash is cached for the build. An item with no .njk files copies without evaluating it. A supplier exception propagates directly; a template rendering failure throws Skilletor::Error::Render.
executables
executables( $item, $source_dir );
The install paths, as a hash set, of the files whose source has the owner's executable bit.
renders_empty
renders_empty( $item, $output );
True when the item's main file (SKILL.md, <name>.md) is a template whose output is whitespace only once a leading frontmatter block is removed: the item does not apply in this scope (renders-empty). False for a main file that is no template.
install_path
install_path( $item, 'plugins/x/skills/foo/SKILL.md' ); # skills/foo/SKILL.md
templates_of
The item's .njk files, relative to its source tree.
SUPPORT
Issues
Please report bugs and feature requests at https://github.com/Getty/skilletor/issues.
CONTRIBUTING
Contributions are welcome! Please fork the repository and submit a pull request.
AUTHOR
Torsten Raudssus <torsten@raudssus.de>
COPYRIGHT AND LICENSE
This software is Copyright (c) 2026 by Torsten Raudssus <torsten@raudssus.de> https://raudssus.de/.
This is free software, licensed under:
The Artistic License 2.0 (GPL Compatible)