/wax

Web preprocessor written in Rust

Primary LanguageRustMIT LicenseMIT

Wax


Very experimental, and early access version of the Wax compiler.
The current CLI uploaded to crates.io is an old version which can be found on the legacy branch.

Install

Install the Wax cli using cargo :

$ cargo install wax-cli

Useage

Create new project
$ wax create <NAME>
Build your project
$ wax build <PATH>

Project Structure

./<my-wax-site>/* 
  │
  ├─ .wax       - # Wax file cache
  ├─ build/     - # Wax build output
  │
  ├─ src/*
  │  ├─ lib/        - # Wax components (*.wx)
  │  ├─ pages/      - # Wax page components (*.wx)
  │  ├─ index.html  - # Html template file
  │  └─ ...
  │
  └─ wax.toml   - # Wax config file

Wax Syntax

Wax components are build out of three parts.

Templates

Contain Html that can be inserted into other templates using the insert (<-) operator.

Example : Wax Html Template
tmpl Hello:
  <p>Hello, World!</p>;

tmpl @base:
  <-Hello />; <!-- <p>Hello, World!</p> -->

@base is a special tag which makes this template the basis for a page.
Every component within the /pages dir should have an @base template.

Stylesheets

Contain Css that is linked to a template of the same name.

Example : Wax Css Stylesheet
tmpl Hello:
  <p>Hello, World!</p>;

styl Hello {
  p {
    color: red;
  }
}

Implementations (wip)

Contain Javascript that is linked to a template of the same name.
Example : Wax JS Implementation
tmpl Hello:
  <p #paragraph>Hello, World!</p>;

impl Hello {
  #paragraph.textContent = 'Hello, Wax!';
}

Using Statements (wip)

Allow you to import Wax components within other Wax components.
Example : Wax Using Statement
use Hello from "./lib/hello.wx";

tmpl @base:
  <-Hello />; <!-- <p>Hello, World!</p> -->

Config

* ? : means it is optional
# wax.toml

[website]
pages = "RelativePath"  # Path to the directory containing your index.html.

[build]
minify = "Boolean?"     # If enabled, will minify the collapsed HTML files.