mirror of
https://github.com/pantor/inja.git
synced 2026-10-07 04:47:16 +00:00
add first and last function
This commit is contained in:
1 parent
6153720155
commit
8af2762829
3 files changed
+27
-1
No files matched your search
@@ -99,6 +99,16 @@ TEST_CASE("functions") {
|
||||
// CHECK_THROWS_WITH( env.render("{{ length(5) }}", data), "[json.exception.type_error.302] type must be array, but is number" );
|
||||
}
|
||||
|
||||
SECTION("first") {
|
||||
CHECK( env.render("{{ first(names) }}", data) == "Jeff" );
|
||||
// CHECK_THROWS_WITH( env.render("{{ length(5) }}", data), "[json.exception.type_error.302] type must be array, but is number" );
|
||||
}
|
||||
|
||||
SECTION("last") {
|
||||
CHECK( env.render("{{ last(names) }}", data) == "Tom" );
|
||||
// CHECK_THROWS_WITH( env.render("{{ length(5) }}", data), "[json.exception.type_error.302] type must be array, but is number" );
|
||||
}
|
||||
|
||||
SECTION("round") {
|
||||
CHECK( env.render("{{ round(4, 0) }}", data) == "4.0" );
|
||||
CHECK( env.render("{{ round(temperature, 2) }}", data) == "25.68" );
|
||||
|
||||
Reference in new issue
Block a user