diff --git a/src/clj_jtwig/standard_functions.clj b/src/clj_jtwig/standard_functions.clj index 4301477..3271d97 100644 --- a/src/clj_jtwig/standard_functions.clj +++ b/src/clj_jtwig/standard_functions.clj @@ -64,6 +64,10 @@ (apply min (first numbers)) (apply min numbers)))} + "normalize_space" + {:fn (fn [s] + (StringUtils/normalizeSpace s))} + "pad_left" {:fn (fn [s size & [padding-string]] (StringUtils/leftPad s size (or padding-string " ")))} diff --git a/test/clj_jtwig/functions_test.clj b/test/clj_jtwig/functions_test.clj index 8295128..33f72c8 100644 --- a/test/clj_jtwig/functions_test.clj +++ b/test/clj_jtwig/functions_test.clj @@ -326,6 +326,10 @@ (is (= (render "{{ min(2, 1, 5, 3, 4) }}" nil) "1"))) + (testing "normalize_space" + (is (= (render "{{ normalize_space(' hello world ') }}" nil) + "hello world"))) + (testing "pad_left" (is (= (render "{{ pad_left('bat', 5) }}" nil) " bat"))