ers is an ERb-style templating language for Rust.
ers templates will be turned into statically compiled Rust functions at your will, allowing you to link them to your other projects.
The library infrastructure is largely inspired by ego.
Using the Makefile should be enough to build the main transpiler:
make ers
In order to compile a template foo.ers like:
<%! pub fn Template(writer: &mut Writer, i: int) %>
<%% use std::io; %%>
<body>
<% for n in range(0, i - 1) { %>
<p>
<%= n + 1 %>
</p>
<% } %>
</body>into a pure Rust function, run:
bin/ers foo.ers foo.rs
Now that the template function is done, use the Template function in your code, say my-file.rs, like this:
extern crate foo;
use std::io::stdio::stdout;
use std::io::BufferedWriter;
use foo::Template;
fn main() {
foo::Template(&mut BufferedWriter::new(~stdout() as ~Writer), 4);
}Compiling and running the my-file program will output:
<body>
<p>
1
</p>
<p>
2
</p>
<p>
3
</p>
</body>GPLv3. Copyright Franck Verrot - 2014.