Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release/0.9.1 #71

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ cache:
- target

rust:
- 1.16.0
- 1.17.0
- stable
- nightly
- beta
Expand Down
6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,21 @@ name = "mustache"
description = "Rust implementation of Mustache"
repository = "https://github.com/nickel-org/rust-mustache"
documentation = "http://nickel-org.github.io/rust-mustache"
version = "0.9.0"
version = "0.9.1"
authors = ["[email protected]"]
license = "MIT/Apache-2.0"

[features]
unstable = []

[dependencies]
log = "0.3.5"
log = "0.4"
serde = "1.0.0"

[dev-dependencies]
serde_derive = "1.0.0"
serde_json = "1.0.0"
tempdir = "0.3.4"
tempfile = "3"

[[test]]
name = "test"
Expand Down
5 changes: 5 additions & 0 deletions src/template.rs
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,11 @@ impl<'a> RenderContext<'a> {
try!(self.render(wr, stack, &tokens));
}

Data::Bool(val) => {
let s = if val { "true" } else { "false" };
try!(self.write_tracking_newlines(wr, s));
}

ref value => {
bug!("render_utag: unexpected value {:?}", value);
}
Expand Down
49 changes: 47 additions & 2 deletions tests/template.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use std::cell::RefCell;
use tempdir::TempDir;
use tempfile::Builder;
use std::fmt::Debug;
use std::fs::File;
use std::io::Write;
Expand Down Expand Up @@ -216,6 +216,51 @@ mod context_search {
assert_eq!(rendered, expected);
}

#[test]
fn renders_bool() {
let template = compile_str(
"{{bool}}
#map{{#outer}}
{{#bool}}
#bool
#vec{{#inner}}{{{.}}}{{/inner}}/vec
{{/bool}}\n\
{{^not_ok}}
^not_ok
#vec{{#inner}}{{{.}}}{{/inner}}/vec
{{/not_ok}}\n\
{{/outer}}
/map
{{ok}}");
let ctx = MapBuilder::new()
.insert_bool("bool", false)
.insert_bool("not_ok", false)
.insert_map("outer", |map| {
map.insert_bool("bool", true)
.insert_vec("inner", |vec| {
vec.push_bool(false)
.push_bool(true)
.push_bool(false)
})
})
.insert_bool("ok", true)
.build();

let expected = "false
#map
#bool
#vecfalsetruefalse/vec

^not_ok
#vecfalsetruefalse/vec

/map
true";
let rendered = render_data(&template, &ctx);
println!("{}\n----\n{}", rendered, expected);
assert_eq!(rendered, expected);
}

#[test]
fn from_base() {
let template = "\
Expand Down Expand Up @@ -493,7 +538,7 @@ fn run_test(test: serde_json::Map<String, Json>, data: Data) {

// Make a temporary dir where we'll store our partials. This is to
// avoid a race on filenames.
let tmpdir = TempDir::new("").expect("Failed to make tempdir");
let tmpdir = Builder::new().tempdir().expect("Failed to make tempdir");

if let Some(value) = test.get("partials") {
write_partials(tmpdir.path(), value)
Expand Down
2 changes: 1 addition & 1 deletion tests/test.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
extern crate mustache;
extern crate serde;
extern crate serde_json;
extern crate tempdir;
extern crate tempfile;

#[macro_use] extern crate serde_derive;

Expand Down