Project Name | Stars | Downloads | Repos Using This | Packages Using This | Most Recent Commit | Total Releases | Latest Release | Open Issues | License | Language |
---|---|---|---|---|---|---|---|---|---|---|
Milk | 194 | 8 | 5 | 6 years ago | 6 | May 08, 2011 | 4 | CoffeeScript | ||
Milk is Mustache in CoffeeScript -- great with your browser or NodeJS! | ||||||||||
Rust Mustache | 132 | 241 | 26 | 2 years ago | 12 | February 12, 2018 | 15 | other | Rust | |
mustache template library for rust | ||||||||||
Mustache | 84 | 24 | a year ago | 28 | March 23, 2022 | 7 | other | Haskell | ||
Haskell implementation of mustache templates | ||||||||||
Bart | 30 | 5 | 4 | 3 months ago | 7 | January 05, 2023 | 7 | mit | Rust | |
A compile time templating language for Rust inspired by Mustache | ||||||||||
Acutis | 20 | 2 days ago | 1 | mpl-2.0 | OCaml | |||||
A declarative, type-safe template language | ||||||||||
Php Mustache | 8 | 10 years ago | PHP | |||||||
Mustache template parser, compiler and interpreter in PHP. | ||||||||||
Tint | 4 | 3 months ago | mit | JavaScript | ||||||
A natural template engine for the HTML DOM | ||||||||||
Cmustache | 4 | 12 years ago | ||||||||
C implementation of the Mustache logic-less templating language | ||||||||||
Malline | 3 | 5 years ago | mit | Swift | ||||||
Templating engine for Swift, similar to Handlebars & Mustache. | ||||||||||
Mustaml | 3 | 11 years ago | 1 | PHP | ||||||
Mustaml is a html template language, logic-less and neat. |
Inspired by ctemplate and et, Mustache is a framework-agnostic way to render logic-free views.
As ctemplates says, "It emphasizes separating logic from presentation: it is impossible to embed application logic in this template language."
rust-mustache is a rust implementation of Mustache.
The different Mustache tags are documented at mustache(5).
Documentation for this library is here.
Install it through Cargo!
[dependencies]
mustache = "*"
#[macro_use]
extern crate serde_derive;
extern crate mustache;
use std::io;
use mustache::MapBuilder;
#[derive(Serialize)]
struct Planet {
name: String,
}
fn main() {
// First the string needs to be compiled.
let template = mustache::compile_str("hello {{name}}").unwrap();
// You can either use an encodable type to print "hello Mercury".
let planet = Planet { name: "Mercury".into() };
template.render(&mut io::stdout(), &planet).unwrap();
println!("");
// ... or you can use a builder to print "hello Venus".
let data = MapBuilder::new()
.insert_str("name", "Venus")
.build();
template.render_data(&mut io::stdout(), &data).unwrap();
println!("");
// ... you can even use closures.
let mut planets = vec!("Jupiter", "Mars", "Earth");
let data = MapBuilder::new()
.insert_fn("name", move |_| {
planets.pop().unwrap().into()
})
.build();
// prints "hello Earth"
template.render_data(&mut io::stdout(), &data).unwrap();
println!("");
// prints "hello Mars"
template.render_data(&mut io::stdout(), &data).unwrap();
println!("");
// prints "hello Jupiter"
template.render_data(&mut io::stdout(), &data).unwrap();
println!("");
}
Simply clone and run:
# If you want to run the test cases, you'll need the spec as well.
git submodule init
git submodule update
cargo test
# If you want to test the readme example, we're currently using the unstable feature to do so.
cargo +nightly test --features unstable
If cutting a new release, please follow something along the lines of the below:
# Assuming master is the current release commit, ideally it will be a commit
# announcing the release and the only change would be the version number.
# Ensure everything looks good
cargo publish --dry-run
# Actually publish
cargo publish
# Tag the release, prefix it with 'v' for easy tag searching, i.e. git tag --list 'v*'
git tag vX.Y.Z
git push --tags origin master
See LICENSE File