From d807f45091752236e59aa0ebfdc920e9dc9c0fb1 Mon Sep 17 00:00:00 2001 From: gered Date: Sun, 23 Mar 2014 11:31:35 -0400 Subject: [PATCH] add normalize_space --- src/clj_jtwig/standard_functions.clj | 4 ++++ test/clj_jtwig/functions_test.clj | 4 ++++ 2 files changed, 8 insertions(+) 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"))