add capitalize_all
This commit is contained in:
parent
2a448b2839
commit
b8c938b2ea
|
@ -6,4 +6,5 @@
|
||||||
:repositories [["sonatype" {:url "http://oss.sonatype.org/content/repositories/releases"
|
:repositories [["sonatype" {:url "http://oss.sonatype.org/content/repositories/releases"
|
||||||
:snapshots false}]]
|
:snapshots false}]]
|
||||||
:dependencies [[org.clojure/clojure "1.5.1"]
|
: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"]])
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
(ns clj-jtwig.standard-functions
|
(ns clj-jtwig.standard-functions
|
||||||
"standard function definitions. these are functions that are not yet included in JTwig's standard function
|
"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."
|
library and are just here to fill in the gaps for now."
|
||||||
|
(:import (org.apache.commons.lang3.text WordUtils))
|
||||||
(:use [clojure.pprint]))
|
(:use [clojure.pprint]))
|
||||||
|
|
||||||
; we are using a separate map to hold the standard functions instead of using deftwigfn, etc. because doing it this
|
; 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)
|
(-> sequence vals butlast)
|
||||||
(butlast sequence)))}
|
(butlast sequence)))}
|
||||||
|
|
||||||
|
"capitalize_all"
|
||||||
|
{:fn (fn [s]
|
||||||
|
(WordUtils/capitalize s))}
|
||||||
|
|
||||||
"dump"
|
"dump"
|
||||||
{:fn (fn [x]
|
{:fn (fn [x]
|
||||||
(with-out-str
|
(with-out-str
|
||||||
|
|
|
@ -284,6 +284,10 @@
|
||||||
(is (= (render "{{ [1, 2, 3, 4, 5]|butlast }}" nil)
|
(is (= (render "{{ [1, 2, 3, 4, 5]|butlast }}" nil)
|
||||||
"[1, 2, 3, 4]")))
|
"[1, 2, 3, 4]")))
|
||||||
|
|
||||||
|
(testing "capitalize_all"
|
||||||
|
(is (= (render "{{ capitalize_all('hello world') }}" nil)
|
||||||
|
"Hello World")))
|
||||||
|
|
||||||
(testing "dump"
|
(testing "dump"
|
||||||
(is (= (render "{{ a|dump }}" {:a [{:foo "bar"} [1, 2, 3] "hello"]})
|
(is (= (render "{{ a|dump }}" {:a [{:foo "bar"} [1, 2, 3] "hello"]})
|
||||||
"({\"foo\" \"bar\"} (1 2 3) \"hello\")\n")))
|
"({\"foo\" \"bar\"} (1 2 3) \"hello\")\n")))
|
||||||
|
|
Reference in a new issue