#web #site #configuration #command #name #template #run

bin+lib caer

Tools for making things on the web

1 unstable release

0.1.0 Feb 24, 2024

#248 in Template engine

AGPL-3.0-only

66KB
1K SLoC

Tools for making things on the web.

We could claim the name is an acronym for "Caer's Assorted Engineering Resources", but who are we kidding?

Getting Started

First, install Rust. Then run:

cargo install caer

Once the installation finishes, run caer to see a list of commands and how to use them.

Configuration

Many of the commands rely on a configuration file, which by default is a Config.toml in the current working directory.

If this file doesn't exist, a default config will be created automatically, containing all possible configuration options, along with comments explaining what the options do.

The Tools

Build Static Websites with site

When invoking the site subcommand, the following kinds of files will be built:

  • .md files are compiled to .html files, and all internal links are canonicalized relative to the site root URL.
  • .scss files are compiled to minified .css files.
  • .html files are compiled to minified .html files.
  • .js files are compiled to minified .js files.
  • favicon.png files are converted to favicon.ico files.

Files and directories starting with _ will be available for inclusion by other files, but will not be included in the output directory.

All other files will be copied to the output directory as-is, with no compilation.

Templates for Built Files

All built files that contain UTF-8 encoded text may optionally contain template directives. These directives always begin with {> and end with }.

For example, given the following HTML file:

<h1>{> name}'s Blog Posts</h1>
{> for post in posts}
<div class="post">
    <h2>{> post.title}</h2>
    <p>{> post.summary}</p>
</div>
{> end}

And a default context in the Config.toml containing the following values:

name = "Caer"

[[posts]]
title = "Templating is great."
summary = "Very, very great."

[[posts]]
title = "My First Post!"
summary = "Lorem, Ipsum, Something."

The HTML file will be built into:

<h1>Caer's Blog Posts</h1>

<div class="post">
    <h2>Templating is great.</h2>
    <p>Very, very great.</p>
</div>

<div class="post">
    <h2>My First Post!</h2>
    <p>Lorem, Ipsum, Something</p>
</div>

To view a full list of the possible templating options, please refer to the templating code.

License and Contributions

Copyright 2024 Brandon Sanders.

Licensed under the GNU Affero General Public License version 3, as published by the Free Software Foundation. Refer to the license file for more information.

Dependencies

~19–34MB
~492K SLoC