mirror of
https://github.com/pantor/inja.git
synced 2026-10-18 01:38:14 +00:00
show location for render errors
This commit is contained in:
1 parent
0398edd419
commit
d25a4de54f
14 files changed
+334
-279
No files matched your search
+2
-2
@@ -255,9 +255,9 @@ std::string string_template {
|
||||
"cupiditate nostrum iure. Voluptatem accusamus vel corporis. \n Debitis {{ name }} sunt est debitis distinctio ut. "
|
||||
"Provident corrupti nihil velit aut tempora corporis corrupti exercitationem. Praesentium cumque ex est itaque."};
|
||||
|
||||
BENCHMARK(InjaBenchmarkerSmallData, render, 10, 100) { env.render(string_template, smallData); }
|
||||
BENCHMARK(InjaBenchmarkerSmallData, render, 5, 50) { env.render(string_template, smallData); }
|
||||
|
||||
BENCHMARK(InjaBenchmarkerLargeData, render, 10, 100) { env.render(string_template, largeData); }
|
||||
BENCHMARK(InjaBenchmarkerLargeData, render, 5, 25) { env.render(string_template, largeData); }
|
||||
|
||||
int main() {
|
||||
hayai::ConsoleOutputter consoleOutputter;
|
||||
|
||||
@@ -7,5 +7,6 @@
|
||||
],
|
||||
"views": 123,
|
||||
"title": "Inja works.",
|
||||
"content": "Inja is the best and fastest template engine for C++. Period."
|
||||
"content": "Inja is the best and fastest template engine for C++. Period.",
|
||||
"footer-text": "This is the footer."
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
<footer>
|
||||
<div>
|
||||
<h3>About</h3>
|
||||
<p>{{ footer-text }}</p>
|
||||
</div>
|
||||
</footer>
|
||||
@@ -0,0 +1,3 @@
|
||||
<head>
|
||||
<title>{{ title }}</title>
|
||||
</head>
|
||||
@@ -15,5 +15,12 @@
|
||||
<li>test</li>
|
||||
<li>templates</li>
|
||||
</ul>
|
||||
|
||||
<footer>
|
||||
<div>
|
||||
<h3>About</h3>
|
||||
<p>This is the footer.</p>
|
||||
</div>
|
||||
</footer>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,8 +1,6 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>{{ title }}</title>
|
||||
</head>
|
||||
{% include "header.txt" %}
|
||||
<body>
|
||||
<h1>{{ title }}</h1>
|
||||
<small>Written by {{ author }}</small>
|
||||
@@ -16,5 +14,7 @@
|
||||
<li>{{ tag }}</li>
|
||||
## endfor
|
||||
</ul>
|
||||
|
||||
{% include "footer.txt" %}
|
||||
</body>
|
||||
</html>
|
||||
+1
-1
@@ -44,7 +44,7 @@ TEST_CASE("complete-files") {
|
||||
for (std::string test_name : {"error-unknown"}) {
|
||||
SUBCASE(test_name.c_str()) {
|
||||
CHECK_THROWS_WITH(env.render_file_with_json_file(test_name + "/template.txt", test_name + "/data.json"),
|
||||
"[inja.exception.parser_error] (at 2:11) expected 'in', got 'ins'");
|
||||
"[inja.exception.parser_error] (at 2:10) expected 'in', got 'ins'");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -45,7 +45,7 @@ TEST_CASE("types") {
|
||||
CHECK(env.render("Hello {{ brother.daughter0.name }}!", data) == "Hello Maria!");
|
||||
CHECK(env.render("{{ \"{{ no_value }}\" }}", data) == "{{ no_value }}");
|
||||
|
||||
CHECK_THROWS_WITH(env.render("{{unknown}}", data), "[inja.exception.render_error] variable 'unknown' not found");
|
||||
CHECK_THROWS_WITH(env.render("{{unknown}}", data), "[inja.exception.render_error] (at 1:3) variable 'unknown' not found");
|
||||
}
|
||||
|
||||
SUBCASE("comments") {
|
||||
@@ -74,7 +74,7 @@ TEST_CASE("types") {
|
||||
CHECK_THROWS_WITH(env.render("{% for name ins names %}a{% endfor %}", data),
|
||||
"[inja.exception.parser_error] (at 1:13) expected 'in', got 'ins'");
|
||||
CHECK_THROWS_WITH(env.render("{% for name in empty_loop %}a{% endfor %}", data),
|
||||
"[inja.exception.render_error] variable 'empty_loop' not found");
|
||||
"[inja.exception.render_error] (at 1:16) variable 'empty_loop' not found");
|
||||
// CHECK_THROWS_WITH( env.render("{% for name in relatives %}{{ name }}{% endfor %}", data),
|
||||
// "[inja.exception.json_error] [json.exception.type_error.302] type must be array, but is object" );
|
||||
}
|
||||
@@ -281,7 +281,7 @@ TEST_CASE("functions") {
|
||||
CHECK(env.render("{{ default(surname, \"nobody\") }}", data) == "nobody");
|
||||
CHECK(env.render("{{ default(surname, \"{{ surname }}\") }}", data) == "{{ surname }}");
|
||||
CHECK_THROWS_WITH(env.render("{{ default(surname, lastname) }}", data),
|
||||
"[inja.exception.render_error] variable 'lastname' not found");
|
||||
"[inja.exception.render_error] (at 1:21) variable 'lastname' not found");
|
||||
}
|
||||
|
||||
SUBCASE("exists") {
|
||||
@@ -297,9 +297,9 @@ TEST_CASE("functions") {
|
||||
CHECK(env.render("{{ existsIn(brother, property) }}", data) == "true");
|
||||
CHECK(env.render("{{ existsIn(brother, name) }}", data) == "false");
|
||||
CHECK_THROWS_WITH(env.render("{{ existsIn(sister, \"lastname\") }}", data),
|
||||
"[inja.exception.render_error] variable 'sister' not found");
|
||||
"[inja.exception.render_error] (at 1:13) variable 'sister' not found");
|
||||
CHECK_THROWS_WITH(env.render("{{ existsIn(brother, sister) }}", data),
|
||||
"[inja.exception.render_error] variable 'sister' not found");
|
||||
"[inja.exception.render_error] (at 1:22) variable 'sister' not found");
|
||||
}
|
||||
|
||||
SUBCASE("isType") {
|
||||
@@ -440,7 +440,7 @@ TEST_CASE("other-syntax") {
|
||||
CHECK(env.render("Hello {{ brother/daughter0/name }}!", data) == "Hello Maria!");
|
||||
|
||||
CHECK_THROWS_WITH(env.render("{{unknown/name}}", data),
|
||||
"[inja.exception.render_error] variable 'unknown/name' not found");
|
||||
"[inja.exception.render_error] (at 1:3) variable 'unknown/name' not found");
|
||||
}
|
||||
|
||||
SUBCASE("other expression syntax") {
|
||||
|
||||
Reference in new issue
Block a user