#templating #string #cli

bin+lib nanotemplate

A minimal templating engine that renders a string from the template, replacing all instances of {placeholder} with given values

4 releases (2 breaking)

0.3.0 Sep 22, 2022
0.2.1 Jun 23, 2021
0.2.0 May 5, 2021
0.1.0 May 4, 2021

#181 in Template engine

Download history 390/week @ 2024-01-10 365/week @ 2024-01-17 465/week @ 2024-01-24 558/week @ 2024-01-31 538/week @ 2024-02-07 714/week @ 2024-02-14 786/week @ 2024-02-21 767/week @ 2024-02-28 1155/week @ 2024-03-06 1418/week @ 2024-03-13 238/week @ 2024-03-20 1380/week @ 2024-03-27 433/week @ 2024-04-03 369/week @ 2024-04-10 341/week @ 2024-04-17 468/week @ 2024-04-24

1,703 downloads per month
Used in 2 crates

MIT license

17KB
298 lines

Latest Version Documentation License

A minimal templating engine that renders a string from the template, replacing all instances of {placeholder} with given values.

The engine is strict:

  • all placeholders must have values provided (use template_default to use default value for placeholders),
  • all provided values must have matching placeholder (when using template_strict),
  • a single placeholder can be used multiple times and will be expanded in all places.

Values are provided as an iterable object that provides placeholder name and value pairs.

use nanotemplate::template;

assert_eq!(
	template("Hello, my name is {name}!", &[("name", "nanotemplate")]).unwrap(),
	"Hello, my name is nanotemplate!".to_owned());

Also comes with simple CLI utility:

echo "Hello my name is {name}" | nanotemplate name=nanotemplate

No runtime deps