RDXL Static Site Generation Template

Clone the Github Repository

Our first step to use the static site template will be to clone the repository from Github. This will provide us with a barebone website that just generates an index file. To do this the template defines one template as the default template. Then this template is applied in an html page named index.html

git clone https://github.com/andrew-johnson-4/rdxl_static_template.git
cd rdxl_static_template
cargo test

Inspect the Contents of the Template Project

To understand and start to build your own website it is important to understand some basic concepts from rdlx_static. If you inspect the template project you will find that all of the code is located in the tests directory. The reason for placing all RDXL code in the tests directory is to allow for easy manipulation of the root folder where static files will be placed at the end of the static build process. For example, if you make a tests/www.rs test, then all content from that build will be placed in a www/ directory in the package root. If you have multiple sites or folders to build to, generating more directories is as easy as creating more test modules. Nested folders can be created by simply nesting test modules inside of other test modules. A www::css package will generate output into a www/css/ folder.

How does #[dot_template] work?

The dot_template attribute macro works by creating a struct to act as a builder for the function that is wrapped. The builder looks at each argument to the template function and generates a default value and a setter for the builder. The template is then referenced by the dot_html! macro to construct a formatted String based on the required and optional arguments of the builder.

How does dot_html! work?

The dot_html! macro just invokes the builder of a template to format the provided arguments into a formatted string. The desugared syntax of a builder invocation can be seen in the tests/ folder of rdxl_static.

What is dot_include!?

The dot_include! macro interprets a relative file as Rust code inside of an anonymous function. The macro returns a tuple containing the (url path, and the function) to be used in generating the static output of the site generation. A simple static site generator will just write these function outputs to files.