mirror of
https://github.com/pantor/inja.git
synced 2026-07-10 02:55:10 +00:00
fix include of in-memory templates
This commit is contained in:
+15
-3
@@ -73,7 +73,19 @@ TEST_CASE("include-without-local-files") {
|
||||
inja::Environment env {test_file_directory};
|
||||
env.set_search_included_templates_in_files(false);
|
||||
|
||||
SUBCASE("html") {
|
||||
CHECK_THROWS_WITH(env.render_file_with_json_file("html/template.txt", "html/data.json"), "[inja.exception.render_error] (at 3:14) include '../test/data/html/header.txt' not found");
|
||||
}
|
||||
CHECK_THROWS_WITH(env.render_file_with_json_file("html/template.txt", "html/data.json"), "[inja.exception.render_error] (at 3:14) include 'header.txt' not found");
|
||||
}
|
||||
|
||||
TEST_CASE("include-in-memory-and-file-template") {
|
||||
inja::Environment env {test_file_directory};
|
||||
|
||||
json data;
|
||||
data["name"] = "Jeff";
|
||||
|
||||
CHECK_THROWS_WITH(env.render_file("include-both.txt", data), "[inja.exception.file_error] failed accessing file at '../test/data/body'");
|
||||
|
||||
const auto parsed_body_template = env.parse("Bye {{ name }}.");
|
||||
env.include_template("body", parsed_body_template);
|
||||
|
||||
CHECK(env.render_file("include-both.txt", data) == "Hello Jeff. - Bye Jeff.");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user