Ructe

screenshot of Ructe

Rust Compiled Templates with static-file handling

Overview:

Rust Compiled Templates, also known as ructe, is a HTML template system that aims to make writing templates in Rust as easy as writing HTML. It draws inspiration from the scala template system used in play 2 and plain old jsp. The main design criteria of ructe is to catch as many errors as possible at compile-time, include all the template code in the compiled binary to avoid reading template files at runtime, have fast running times, and provide an expressive template language that can be used for any text-like format, not just HTML. Templates written with ructe can be transpiled to Rust functions that can be compiled and called from Rust code.

Features:

  • Compile-time Error Catching: Ructe aims to catch as many errors as possible at compile-time, reducing the chances of runtime errors.
  • Include All Template Code in Compiled Binary: The compiled binary includes all the template code it needs, eliminating the need to read template files at runtime.
  • Fast Running Times: While compilation may take some time, the running times of templates should be fast.
  • Easy Template Writing: Ructe aims to make writing templates almost as easy as writing HTML.
  • Expressive Template Language: The template language used in ructe is designed to be as expressive as possible, allowing for templates to be written for any text-like format, not just HTML.
  • Output any value that implements Display trait: Ructe allows for any value that implements the Display trait to be outputted in the templates.
  • HTML Escaping by Default: By default, all values are HTML-escaped in the templates. However, there is an easy but explicit way to output preformatted HTML.

Summary:

Rust Compiled Templates (ructe) is a HTML template system for Rust that aims to provide an easy and expressive way to write templates for any text-like format, not just HTML. It focuses on catching errors at compile-time, including all the template code in the compiled binary, and providing fast running times. With ructe, templates can be transpiled to Rust functions that can be compiled and called from Rust code. By default, ructe escapes all values in the templates, but also provides a way to output preformatted HTML. It is currently in an early stage of development but is functional and includes documentation and examples for various web frameworks.