From fdcd0d74d3215682f9c7b25a47a082c9408702ff Mon Sep 17 00:00:00 2001 From: gered Date: Tue, 4 Mar 2014 14:37:48 -0500 Subject: [PATCH] add alias for "blankIfNull" --- src/clj_jtwig/standard_functions.clj | 3 ++- test/clj_jtwig/functions_test.clj | 4 +++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/clj_jtwig/standard_functions.clj b/src/clj_jtwig/standard_functions.clj index 1d591d9..a4a034f 100644 --- a/src/clj_jtwig/standard_functions.clj +++ b/src/clj_jtwig/standard_functions.clj @@ -13,7 +13,8 @@ (defonce standard-functions {"blankIfNull" {:fn (fn [x] - (if (nil? x) "" x))} + (if (nil? x) "" x)) + :aliases ["nonull"]} "butlast" {:fn (fn [sequence] diff --git a/test/clj_jtwig/functions_test.clj b/test/clj_jtwig/functions_test.clj index 1aa1db8..09be3ba 100644 --- a/test/clj_jtwig/functions_test.clj +++ b/test/clj_jtwig/functions_test.clj @@ -250,7 +250,9 @@ (is (= (render "{{ a|blankIfNull }}" {:a nil}) "")) (is (= (render "{{ a|blankIfNull }}" {:a "foo"}) - "foo"))) + "foo")) + (is (= (render "{{ a|nonull }}" nil) + ""))) (testing "butlast" (is (= (render "{{ [1, 2, 3, 4, 5]|butlast }}" nil)