add capitalize_all

This commit is contained in:
Gered 2014-03-23 10:28:40 -04:00
parent 2a448b2839
commit b8c938b2ea
3 changed files with 11 additions and 1 deletions

View file

@ -6,4 +6,5 @@
:repositories [["sonatype" {:url "http://oss.sonatype.org/content/repositories/releases"
:snapshots false}]]
:dependencies [[org.clojure/clojure "1.5.1"]
[com.lyncode/jtwig-core "2.1.2"]])
[com.lyncode/jtwig-core "2.1.2"]
[org.apache.commons/commons-lang3 "3.1"]])

View file

@ -1,6 +1,7 @@
(ns clj-jtwig.standard-functions
"standard function definitions. these are functions that are not yet included in JTwig's standard function
library and are just here to fill in the gaps for now."
(:import (org.apache.commons.lang3.text WordUtils))
(:use [clojure.pprint]))
; we are using a separate map to hold the standard functions instead of using deftwigfn, etc. because doing it this
@ -23,6 +24,10 @@
(-> sequence vals butlast)
(butlast sequence)))}
"capitalize_all"
{:fn (fn [s]
(WordUtils/capitalize s))}
"dump"
{:fn (fn [x]
(with-out-str

View file

@ -284,6 +284,10 @@
(is (= (render "{{ [1, 2, 3, 4, 5]|butlast }}" nil)
"[1, 2, 3, 4]")))
(testing "capitalize_all"
(is (= (render "{{ capitalize_all('hello world') }}" nil)
"Hello World")))
(testing "dump"
(is (= (render "{{ a|dump }}" {:a [{:foo "bar"} [1, 2, 3] "hello"]})
"({\"foo\" \"bar\"} (1 2 3) \"hello\")\n")))