Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/Ryman/nickel-mustache
Flexible Mustache template rendering for nickel
https://github.com/Ryman/nickel-mustache
Last synced: 3 months ago
JSON representation
Flexible Mustache template rendering for nickel
- Host: GitHub
- URL: https://github.com/Ryman/nickel-mustache
- Owner: Ryman
- License: mit
- Created: 2015-11-06T16:10:53.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2016-09-21T04:40:38.000Z (about 8 years ago)
- Last Synced: 2024-05-02T12:39:28.974Z (7 months ago)
- Language: Rust
- Size: 3.13 MB
- Stars: 2
- Watchers: 4
- Forks: 4
- Open Issues: 4
-
Metadata Files:
- Readme: Readme.md
- License: LICENSE
Awesome Lists containing this project
README
# nickel_mustache
Flexible [Mustache](https://mustache.github.io/) support for [nickel.rs](https://github.com/nickel-org/nickel.rs) using
[rust-mustache](https://github.com/nickel-org/rust-mustache).```rust,no_run
#[macro_use] extern crate nickel;
extern crate nickel_mustache;
extern crate rustc_serialize;use nickel_mustache::Render;
use nickel::{Nickel, HttpRouter};fn main() {
let mut server = Nickel::new();server.get("/*", middleware! { |_req, res|
#[derive(RustcEncodable)]
struct ViewData<'a> {
name: &'a str
}let data = ViewData { name: "World" };
return Render::render(res, "examples/assets/my_template", &data)
});server.listen("127.0.0.1:6767");
}
```## Core Features
* Layout support
* Centralized path adjustments
* Optional template compilation caching## Dependencies
You'll need to create a *Cargo.toml* that looks like this;
```toml
[package]name = "my-nickel-app"
version = "0.0.1"
authors = ["yourname"][dependencies]
nickel_mustache = "*"
nickel = "*"
# Some examples require the `rustc_serialize` crate, which will
# require uncommenting the lines below
# rustc-serialize = "*"
```You can then compile this using *Cargo build* and run it using *Cargo run*. After it's running you should visit http://localhost:6767 to see your hello world! (Note: the examples run with randomized ports, so please check the console output for the active port)
## More examples
More examples can be found [in the examples directory](/examples/), please check them out and you are welcome to log an issue if you have any trouble!
Generated documentation can be [found here](http://ryman.github.io/nickel-mustache)