@lucasmelin/spall
v0.0.2
Published
Render Knap templates embedded in Markdown files without disturbing surrounding content.
Readme
Spall
Spall is a small CLI that renders Knap templates embedded directly in Markdown files.
Spall is inspired by Cog, but uses Knap's Markdown-native template language.
Install
npm install -g @lucasmelin/spallUsage
Render a Markdown file containing a template:
npx @lucasmelin/spall render file.md --data data.jsonAll lines between [[[spall:begin and spall:generate]]] are part of the knap template.
The lines between spall:generate]]] and [[[spall:end]]] are the output from the knap template.
For example, if you run this file through spall:
<!--[[[spall:begin
Hello from {{ name }}!
spall:generate]]]-->
<!--[[[spall:end]]]-->with npx @lucasmelin/spall render file.md --set name=Lucas, it would generate:
<!--[[[spall:begin
Hello from {{ name }}!
spall:generate]]]-->
Hello from Lucas!
<!--[[[spall:end]]]-->Line comments and Obsidian comments (%%) are supported as well.
Development
Prerequisites
This project uses Nix flakes to manage the development environment.
Setting up the dev environment
Enter the development shell, which provides Node.js, pnpm, and TypeScript tooling:
nix develop
# Alternatively, if you have direnv installed:
direnv allowInstall dependencies:
pnpm installRunning spall during development
Run the CLI directly against TypeScript source without a build step, using tsx:
pnpx tsx src/cli.ts <args>Or compile first and run the emitted JavaScript:
pnpm build
node dist/cli.js <args>Installing and running via Nix
You don't need nix develop just to run spall, the flake can build and run it directly.
Run without installing anything persistently:
nix run . -- <args>Build the package and invoke the binary directly:
nix build .
./result/bin/spall <args>Install Spall into your Nix profile so it's available on your PATH:
nix profile add .
spall <args>