mirror of
https://github.com/pantor/inja.git
synced 2026-10-05 20:10:36 +00:00
add join function (#204)
* add join function * fix formatting to match single include * add join test * add join to documentation * fix MSVC warning: signed/unsigned mismatch Co-authored-by: Wim Leflere <wleflere@cochlear.com>
This commit is contained in:
co-authored by
Wim Leflere
parent
9cf7db8a06
commit
91c93bfb77
@@ -224,6 +224,10 @@ render("{{ last(guests) }} was last.", data); // "Patir was last."
|
||||
render("{{ sort([3,2,1]) }}", data); // "[1,2,3]"
|
||||
render("{{ sort(guests) }}", data); // "[\"Jeff\", \"Patrick\", \"Tom\"]"
|
||||
|
||||
// Join a list with a separator
|
||||
render("{{ join([1,2,3], \" + \") }}", data); // "1 + 2 + 3"
|
||||
render("{{ join(guests, \", \") }}", data); // "Jeff, Patrick, Tom"
|
||||
|
||||
// Round numbers to a given precision
|
||||
render("{{ round(3.1415, 0) }}", data); // 3
|
||||
render("{{ round(3.1415, 3) }}", data); // 3.142
|
||||
|
||||
Reference in New Issue
Block a user