https://github.com/bbfh-dev/mend.html
Simple HTML template processor designed to, but not limited to be used to generate static websites
https://github.com/bbfh-dev/mend.html
Last synced: about 1 year ago
JSON representation
Simple HTML template processor designed to, but not limited to be used to generate static websites
- Host: GitHub
- URL: https://github.com/bbfh-dev/mend.html
- Owner: bbfh-dev
- License: isc
- Created: 2025-03-06T10:13:42.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2025-03-06T10:44:23.000Z (about 1 year ago)
- Last Synced: 2025-03-06T11:27:14.351Z (about 1 year ago)
- Language: Go
- Homepage:
- Size: 32.2 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# 🔩 mend.html
Mend is a simple HTML template processor designed to, but not limited to be used to generate static websites.
> [!CAUTION]
> This project is currently in **Beta**, meaning that it is NOT production ready.
- [Installation](#installation)
- [Usage](#usage)
- [Example Usage](#example-usage)
- [Language Specification](#language-specification)
- [1. Comment Statements](#1-comment-statements)
- [Extend Statement](#extend-statement)
- [If Statement](#if-statement)
- [Range Statement](#range-statement)
- [Include Statement](#include-statement)
- [Slot Statement](#slot-statement)
- [2. Expression Statements](#2-expression-statements)
# Installation
Download the [latest release](https://github.com/bbfh-dev/mend.html/releases/latest) or install via the command line with:
```bash
go install github.com/bbfh-dev/mend.html
```
# Usage
Run `mend --help` to display usage information.
## Example Usage
```bash
mend build -s '{"title":"Hello World!","filename":"index.html","items":[]}' example/index.html > dist/output.html
```
This command builds the `example/index.html` file along with all its dependencies into `dist/output.html` using the provided JSON parameters.
Note that `mend build` outputs the result into **Stdout**, which is why `>` operator is used to redirect output into a file.
# Language Specification
> [!TIP]
> In the documentation, `[argument]` denotes required arguments and `(argument)` denotes optional ones.
Mend processes a file's content unchanged until it encounters one of two types of mend statements:
## 1. Comment Statements
> [!IMPORTANT]
> Mend comments must be on separate, single lines to be recognized and processed.
There are two types of comment statements:
- `` — A simple inline mend statement.
- `` paired with `` — A mend block used to wrap a section of content.
### Extend Statement
**Syntax:**\
`` ... ``
This statement extends a referenced file. Use the [Slot statement](#slot-statement) within the parent file to define where the child content should be inserted.
### If Statement
**Syntax:**\
`` ... ``
This block conditionally removes its enclosed content if the specified condition evaluates to false.
**Supported Operators:**
- `==` (equals)
- `!=` (does not equal)
- `has` (checks if an array contains a specified element)
- `lacks` (checks if an array does not contain a specified element)
### Range Statement
**Syntax:**\
`` ... ``
This block iterates over an array. To access properties of the current item, prefix the expression with `#` (for example, `{{ #.child_property }}`).
### Include Statement
**Syntax:**\
``
This inline statement inserts the contents of the referenced file directly into the current document.
### Slot Statement
**Syntax:**\
``
This statement marks the insertion point for content when a file is extended. **Note:** Each file can declare only one slot.
## 2. Expression Statements
Expression statements insert values directly into the output.
- An expression beginning with `.` accesses a property from the input JSON (e.g. `{{ .path.to.name }}` retrieves the value at `path.to.name`).
- Using just `.` outputs the entire JSON object (the root).
Expressions can also include modifiers, using the format: `{{ modifier_name .path.to.property }}`.
**Supported Modifiers:**
- `length`, `len`, or `size` — Returns the length of an array.
- `quote` — Wraps the output value in double quotes.