Skip to content

Scribanter simplifies static content generation by providing a command-line wrapper around Scriban. Generate content from JSON models and Scriban templates without complex setup or coding. Ideal for HTML, config files, and more.

Notifications You must be signed in to change notification settings

tmsampson/Scribanter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

58 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Scribanter

Build Status Test Status

Overview

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.

Why Scribanter?

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].

Getting Started

Installation

You have two options for getting started:

Option 1: Download the binaries

  1. Go to the GitHub Releases page.
  2. Download the latest binaries and extract them.

Option 2: Build from source

  1. 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
  2. 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.

  3. Run the init task to set everything up.

  4. Run the build task to compile the tool and tests.

Usage

Scribanter uses a simple CLI interface:

scribanter --model path/to/model.json --template path/to/template.scriban --output path/to/output.html

Examples

Basic Usage

Render a simple template:

scribanter --template path/to/template.scriban \
           --output path/to/output.txt

Using JSON Models

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

Template Includes

Example of including templates and optionally passing in parameters:

{{ include "Header.scriban" title: "My Page Title" }}

Some interesting content.

{{ include "Footer.scriban" }}

Built-in Template Values

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

Path Usage

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

Job Files (Optional)

For batch processing, use a .job file to describe inputs and outputs. Job files are executed as follows:

scribanter --job path/to/some.job

Example 1

Single task, single items (no data model).

{
  "tasks": [
    {
      "items": [
        {
         "template": "Templates/Basic1.scriban",
         "output": "Output/Basic1.txt"
        }
      ]
    }
  ]
}

Example 2

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"
         }
       ]
     },
  ]
}

Example 3

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"
        }
      ]
    }
  ]
}

Example 4

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"
        }
      ]
    },
  ]
}

Contributing

Feel free to fork the project and open pull requests with improvements or new features.

License

MIT


Happy templating with Scribanter! 🚀

About

Scribanter simplifies static content generation by providing a command-line wrapper around Scriban. Generate content from JSON models and Scriban templates without complex setup or coding. Ideal for HTML, config files, and more.

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages