Skip to content

Simple HTML template processor designed to, but not limited to be used to generate static websites

License

Notifications You must be signed in to change notification settings

bbfh-dev/mend.html

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🔩 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

Download the latest release or install via the command line with:

go install github.com/bbfh-dev/mend.html

Usage

Run mend --help to display usage information.

Example Usage

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:
<!-- #extend [filename] (parameters) --> ... <!-- /extend -->

This statement extends a referenced file. Use the Slot statement within the parent file to define where the child content should be inserted.

If Statement

Syntax:
<!-- #if [name] [operator] [value] --> ... <!-- /if -->

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:
<!-- #range [parameter] --> ... <!-- /range -->

This block iterates over an array. To access properties of the current item, prefix the expression with # (for example, {{ #.child_property }}).

Include Statement

Syntax:
<!-- @include [filename] (parameters) -->

This inline statement inserts the contents of the referenced file directly into the current document.

Slot Statement

Syntax:
<!-- @slot -->

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.

About

Simple HTML template processor designed to, but not limited to be used to generate static websites

Resources

License

Stars

Watchers

Forks