- Notifications
You must be signed in to change notification settings - Fork22
A flexible template engine for Rust
rustache/rustache
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
Rustache is aRust implementation of theMustache spec.
The different Mustache tags are documented at themustache(5) man page.
The project's docs page is locatedhere.
Install it throughCargo:
rustache ="^0.1"
Then link it within your crate like so:
externcrate rustache;
The main forward interface that users will interact with when using Rustacheis therender
method provided by therustache::Render
trait like so:
// Renders the given template stringlet data = rustache::HashBuilder::new().insert("name","your name");letmut out =Cursor::new(Vec::new());data.render("{{ name }}",&mut out).unwrap();println!("{}",String::from_utf8(out.into_inner()).unwrap());
Here's an example of how to pass in data to therender_text
method using theHashBuilder
:
let data =HashBuilder::new().insert("name","Bob");letmut out =Cursor::new(Vec::new());data.render("{{ name }}",&mut out);
Here's an example of how to pass in data in the form of a JSONenum
to arender
method:
let data = json::from_str(r#"{"name": "Bob"}"#);letmut out =Cursor::new(Vec::new());data.render("{{ name }}",&mut out);
For more examples please see thetests
directory.
Simply clone and run:
cargotest
Full Mustache spec compliance.
- Comment and Section whitespace handling
- Handle change of delimeters
Thread errors through the parser and compiler:
Real world project examples.
Handle Build and Parser operations concurrently
SeeCONTRIBUTING.md for guidelines on how to contribute.
Copyright (c) 2014 Team Rustache
Permission is hereby granted, free of charge, to any person obtaininga copy of this software and associated documentation files (the"Software"), to deal in the Software without restriction, includingwithout limitation the rights to use, copy, modify, merge, publish,distribute, sublicense, and/or sell copies of the Software, and topermit persons to whom the Software is furnished to do so, subject tothe following conditions:
The above copyright notice and this permission notice shall beincluded in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OFMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE ANDNONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BELIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTIONOF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTIONWITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Inspired byhttps://github.com/erickt/rust-mustache:
Copyright (c) 2012 Erick Tryzelaar
Permission is hereby granted, free of charge, to any person obtaininga copy of this software and associated documentation files (the"Software"), to deal in the Software without restriction, includingwithout limitation the rights to use, copy, modify, merge, publish,distribute, sublicense, and/or sell copies of the Software, and topermit persons to whom the Software is furnished to do so, subject tothe following conditions:
The above copyright notice and this permission notice shall beincluded in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OFMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE ANDNONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BELIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTIONOF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTIONWITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
About
A flexible template engine for Rust
Resources
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Packages0
Uh oh!
There was an error while loading.Please reload this page.
Contributors12
Uh oh!
There was an error while loading.Please reload this page.