mirror of
https://github.com/pantor/inja.git
synced 2026-11-19 14:45:19 +00:00
fix include of in-memory templates
This commit is contained in:
1 parent
ca3c7a0cd6
commit
eac2162629
4 files changed
+30
-16
No files matched your search
+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