Repository navigation
Hooks Authors
Leonard Ramminger edited this page Aug 22, 2026
·
1 revision
Writing Lua hooks in templates.
| File | Phase |
|---|---|
hooks/pre.lua |
Before directory/file creation |
hooks/before_render.lua |
After directories, before Prebyte |
hooks/after_render.lua |
After Prebyte |
hooks/post.lua |
At the end |
hooks/before_render.lua:
write_file("before-render.txt", "before-render\n")| Function | Description |
|---|---|
write_file(path, content) |
Write file in build root |
read_file(path) |
Read (build root or template root) |
mkdir(path) |
Create directory |
remove(path) |
Delete |
exists(path) |
Path exists? |
copy(src, dst) |
Copy |
list_files(dir) |
Filenames in directory |
list_dirs(dir) |
Subdirectories |
process_string(template, values?) |
Prebyte on string |
process_file(src, dst, values?) |
Render Prebyte file |
exec(command) |
Shell command (with timeout) |
get_template_root() |
Absolute template path |
get_build_root() |
Absolute target path |
script(name) |
Run script from scripts/
|
Also: slugify() and metadata helpers as in questions.lua.
scripts/*.lua can be invoked from hooks via script("name"). Reference: advanced_hooks_layout/scripts/create_marker.lua.
- Write only inside the build root
- Read: build root + template files
- Path traversal (
../) is rejected -
execis subject to hook timeout
Details: Security
pre/post can collide across includes - controlled via merge.pre_hook_conflict / merge.post_hook_conflict. before_render / after_render come from the top template.
Fixture with expected hook artifacts: tests/test_templates/advanced_hooks_layout/tests/hooks_and_lock/
tempify test advanced_hooks_layoutTempify · Repository · Issues · Releases
Documentation lives in this wiki. For a build quickstart, see the README in the repository.
Prebyte (template engine) is a separate project bundled by Tempify.
- CLI Reference
- Questions & Answers
- Configuration
- Render Options
- Hooks (Users)
- Reapply & Diff
- Shared Template Store
- Prebyte Passthrough
- Shell Completion