Scribanter is a standalone tool which serves as a lightweight wrapper around Scriban, designed to make static content generation from JSON models and Scriban templates simple and code-free. With Scribanter, you can:
- Generate static HTML pages (or any text-based content) directly from JSON data models.
- Batch process multiple templates and outputs
- Include reusable template components like headers and footers.
- Process single templates via command-line arguments or handle batch processing with a
.job
file.
Existing static site generators can be complex, requiring significant setup and coding. Scribanter reduces the boilerplate by leveraging Scriban and providing an easy-to-use CLI interface. All you need is:
- One or more
.scriban
templates (see Syntax Guide). - A
.json
model containing your data. [Optional] - A
.job
file to handle batch processing [Optional].
You have two options for getting started:
- Go to the GitHub Releases page.
- Download the latest binaries and extract them.
-
Clone the repository:
git clone --recursive https://github.com/yourusername/scribanter.git cd scribanter
Or, if you've already cloned without
--recursive
, run:git submodule update --init --recursive
-
For the best experience, open the repository using Visual Studio Code. This allows the project to be initialised, built and tested via pre-configured tasks.
-
Run the
init
task to set everything up. -
Run the
build
task to compile the tool and tests.
Scribanter uses a simple CLI interface:
scribanter --model path/to/model.json --template path/to/template.scriban --output path/to/output.html
Render a simple template:
scribanter --template path/to/template.scriban \
--output path/to/output.txt
Feed a JSON model into the template:
scribanter --model path/to/animals.json \
--template path/to/print_animals.scriban \
--output path/to/print_animals.txt
Example of including templates and optionally passing in parameters:
{{ include "Header.scriban" title: "My Page Title" }}
Some interesting content.
{{ include "Footer.scriban" }}
Scribanter provides a couple of built-in values you can access directly from within your templates:
{{ TEMPLATE_PATH }} # Path to the template file
{{ TEMPLATE_FILENAME }} # Name of the template file with extension
{{ TEMPLATE_NAME }} # Name of the template file without extension
A few things to note regarding paths:
- Paths passed directly on commandline should be absolute, or relative to the CWD
- Paths used within job files should be absolute, or relative to the .job file
- Paths used in template includes should be absolute or relative to the root template
For batch processing, use a .job
file to describe inputs and outputs. Job files are executed as follows:
scribanter --job path/to/some.job
Single task, single items (no data model).
{
"tasks": [
{
"items": [
{
"template": "Templates/Basic1.scriban",
"output": "Output/Basic1.txt"
}
]
}
]
}
Single task, multiple items, shared data model.
{
"tasks": [
{
"model": "Cars.json",
"items": [
{
"template": "Templates/PrintCars1.scriban",
"output": "Output/CarsA.txt"
},
{
"template": "Templates/PrintCars2.scriban",
"output": "Output/CarsB.txt"
}
]
},
]
}
Multiple tasks (multiple data models).
{
"tasks": [
{
"model": "CarsA.json",
"items": [
{
"template": "Templates/PrintCars.scriban",
"output": "Output/CarsA.txt"
}
]
},
{
"model": "CarsB.json",
"items": [
{
"template": "Templates/PrintCars.scriban",
"output": "Output/CarsB.txt"
}
]
}
]
}
Single task, multiple items, shared data model, now with common template and output folders.
{
"tasks": [
{
"template-dir": "Templates",
"output-dir": "Output",
"model": "Cars.json",
"items": [
{
"template": "PrintCars1.scriban",
"output": "Cars1.txt"
},
{
"template": "PrintCars2.scriban",
"output": "Cars2.txt"
}
]
},
]
}
Feel free to fork the project and open pull requests with improvements or new features.
MIT
Happy templating with Scribanter! 🚀