fix write file bug and readme

This commit is contained in:
pantor
2018-01-28 12:47:56 +01:00
parent 45d128ba0d
commit 3ca727e35d
3 changed files with 8 additions and 12 deletions

View File

@@ -171,13 +171,13 @@ render("{% for i in range(4) %}{{ index1 }}{% endfor %}", data); // "1234"
render("I count {{ length(guests) }} guests.", data); // "I count 3 guests."
// Round numbers to a given precision
render({{ round(3.1415, 0) }}, data) // 3
render({{ round(3.1415, 3) }}, data) // 3.142
render({{ round(3.1415, 0) }}, data); // 3
render({{ round(3.1415, 3) }}, data); // 3.142
// Check if a value is odd, even or divisible by a number
render({{ odd(42) }}, data) // false
render({{ even(42) }}, data) // true
render({{ divisibleBy(42, 7) }}, data) // true
render({{ odd(42) }}, data); // false
render({{ even(42) }}, data); // true
render({{ divisibleBy(42, 7) }}, data); // true
```
### Comments

View File

@@ -59,10 +59,6 @@ add_custom_command(
${CMAKE_SOURCE_DIR}/test/data
${CMAKE_CURRENT_BINARY_DIR}/data
)
add_custom_target(
build-time-make-directory ALL
COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_CURRENT_BINARY_DIR}/results
)
##
## Add tests to make
##

View File

@@ -46,12 +46,12 @@ TEST_CASE("global-path") {
}
TEST_CASE("input-output-path") {
inja::Environment env = inja::Environment("data/", "results/");
inja::Environment env = inja::Environment("data/", "data/");
json data;
data["name"] = "Jeff";
SECTION("Files should be written") {
env.write("simple.txt", data, "result.txt");
CHECK( env.load_global_file("../results/result.txt") == "Hello Jeff." );
env.write("simple.txt", data, "simple-result.txt");
CHECK( env.load_global_file("simple-result.txt") == "Hello Jeff." );
}
}