some minor cleanups

This commit is contained in:
Gered 2014-06-19 17:34:05 -04:00
parent e1a08429bb
commit 97281d6648
6 changed files with 14 additions and 10 deletions

View file

@ -1,5 +1,5 @@
(defproject clj-jtwig "0.5.1"
:description "Clojure wrapper for JTwig"
:description "Clojure wrapper for Jtwig"
:url "https://github.com/gered/clj-jtwig"
:license {:name "Apache License, Version 2.0"
:url "http://www.apache.org/licenses/LICENSE-2.0"}

View file

@ -1,5 +1,5 @@
(ns clj-jtwig.core
"wrapper functions for working with JTwig from clojure"
"wrapper functions for working with Jtwig from clojure"
(:import (com.lyncode.jtwig JtwigTemplate JtwigContext JtwigModelMap)
(com.lyncode.jtwig.content.api Renderable)
(com.lyncode.jtwig.configuration JtwigConfiguration)

View file

@ -1,4 +1,5 @@
(ns clj-jtwig.function-utils
"utility macros for creating Jtwig function handlers. intended for internal clj-jtwig use only."
(:import (com.lyncode.jtwig.functions.exceptions FunctionException)
(com.lyncode.jtwig.functions.annotations JtwigFunction Parameter)
(clj_jtwig TemplateFunction))

View file

@ -10,9 +10,10 @@
(:use [clj-jtwig.standard-functions]
[clj-jtwig.web.web-functions]))
(def object-array-type (Class/forName "[Ljava.lang.Object;"))
(def function-parameters (doto (GivenParameters.)
(.add (to-array [object-array-type]))))
(def ^:private object-array-type (Class/forName "[Ljava.lang.Object;"))
(def ^:private function-parameters (doto (GivenParameters.)
(.add (to-array [object-array-type]))))
(defn- add-function-library! [repository functions]
(doseq [fn-obj functions]
@ -33,11 +34,13 @@
[]
(reset! functions (create-function-repository)))
; intended for internal-use only. mainly exists for use in unit tests
(defn get-function [^String name]
(try
(.get @functions name function-parameters)
(catch FunctionNotFoundException ex)))
; intended for internal-use only. mainly exists for use in unit tests
(defn function-exists? [^String name]
(not (nil? (get-function name))))

View file

@ -1,5 +1,5 @@
(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."
(:import (org.apache.commons.lang3.text WordUtils)
(org.apache.commons.lang3 StringUtils))

View file

@ -4,10 +4,10 @@
[clj-jtwig.core :refer :all]
[clj-jtwig.functions :refer :all]))
; The purpose of these tests is to establish that our wrapper around JTwig works. That is,
; The purpose of these tests is to establish that our wrapper around Jtwig works. That is,
; we will be focusing on stuff like making sure that passing Clojure data structures
; (e.g. maps, vectors, lists) over to JTwig works fine.
; JTwig includes its own test suite which tests actual template parsing and evaluation
; (e.g. maps, vectors, lists) over to Jtwig works fine.
; Jtwig includes its own test suite which tests actual template parsing and evaluation
; functionality, so there's no point in duplicating that kind of testing here once we
; establish that the above mentioned stuff works fine.
;
@ -48,7 +48,7 @@
(set-options! :auto-convert-map-keywords true))))
(deftest passing-model-map-data
(testing "Passing Clojure data structures to JTwigContext's"
(testing "Passing Clojure data structures to JtwigContext's"
(is (= (render "float {{ x }}"
{:x 3.14})
"float 3.14")