gtmpl 0.1.0

The Golang Templating Language for Rust
Documentation

gtmpl-rs ![Build Stats]

The Golang Templating Language for Rust


[dependencies]
gtml = "0.1.0"

Current Limitations

This is work in progress. Currently the following features are not supported:

  • complex numbers
  • comparing different number types
    • eq 1 1.0 will be false
  • the following functions have not been implemented:
    • html, js, call and printf

For now we use serde_json's Value as internal data type. However, this can not support passing functions to the context. In a future release we will move to a custom data type that will be compatible with serde_json.

Usage

Basic template rendering can be achieved in a single line.

extern crate gtmpl;
use gtmpl;

fn basic_template_rendering() {
    let output = gtmpl::template("Finally! Some {{ . }} for Rust", "gtmpl");
    assert_eq!(&output.unwrap(), "Finally! Some gtmpl for Rust");
}

For more examples please take a look at the gtml documentation.

Why do we need this?

The main motivation for this is to make it easier to write dev-ops tools in Rust which feel native. Docker and Helm (Kubernetes) use golang templating and feels more native if tooling around them uses the same.