Every webpage needs some common HTML code. This includes the HTML head preamble and any styles or scripts that you want to use on your page. Here we will use just a normal function to declare the relevant view template. Note that templates in RDXL are statically compiled rust code snippets rather than separate files read in dynamically. The approach of using macros rather than file templates creates some very unique interactions with other Rust libraries that would otherwise be unusable. This is the mix-and-match philosophy of RDXL at work.
use File;
use *;
use xhtml;
use *;
Each individual page of the website will then use the base template. This is a common approach to website templating. RDXL is no different in this aspect. The main differentiating factor of why to use RDXL over other options is that there are no dependencies other than the procedural macros that are only defined and used at compile time. This means that the templates don't care whether they are served from Rocket or some other Rust webserver or whether the templates are being used client-side as part of a WASM application. RDXL is one of the least opinionated templating languages despite some of its more powerful abstractions.
use crate render_page;
use xhtml;
What code blog would be complete without syntax highlighting. Syntect is a great module for escaping and highlighting code samples. It is also pretty simple to use for our case. In place of our html escaper function we will create a wrapper around the syntax highlighter. This function totally transforms our code samples to annotate them with information about syntax for Rust code. Other languages are also available builtin.
use ;
use SyntaxSet;