- Notifications
You must be signed in to change notification settings - Fork65
mustache template library for rust
License
NotificationsYou must be signed in to change notification settings
nickel-org/rust-mustache
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
Inspired byctemplate andet,Mustache is a framework-agnostic wayto render logic-free views.
As ctemplates says, "It emphasizes separating logic from presentation: it isimpossible to embed application logic in this template language."
rust-mustache is a rust implementation of Mustache.
The different Mustache tags are documented atmustache(5).
Documentation for this library ishere.
Install it through Cargo!
[dependencies]mustache ="*"
#[macro_use]externcrate serde_derive;externcrate mustache;use std::io;use mustache::MapBuilder;#[derive(Serialize)]structPlanet{name:String,}fnmain(){// 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.letmut 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 initgit submodule updatecargotest# If you want to test the readme example, we're currently using the unstable feature to do so.cargo +nightlytest --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 goodcargo publish --dry-run# Actually publishcargo publish# Tag the release, prefix it with 'v' for easy tag searching, i.e. git tag --list 'v*'git tag vX.Y.Zgit push --tags origin master
See LICENSE File
About
mustache template library for rust
Resources
License
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Packages0
No packages published
Uh oh!
There was an error while loading.Please reload this page.

