Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into feat-array-access-op
Browse files Browse the repository at this point in the history
  • Loading branch information
erdos committed Aug 20, 2021
2 parents d9636d9 + 246cd2a commit bf59ae8
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 2 deletions.
5 changes: 5 additions & 0 deletions docs/Functions.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ This is a short description of the functions implemented in Stencil:
- [integer](#integer)
- [join](#join)
- [length](#length)
- [list](#list)
- [lowercase](#lowercase)
- [map](#map)
- `percent`
Expand Down Expand Up @@ -63,6 +64,10 @@ of an array or hide the whole paragraph when the array is empty.

<img src="screenshot-function-empty-before.png"/>

### List

Creates a list collection from the supplied arguments. Intended to be used with other collections functions.

### Integer

Converts parameter to integer number. Returns `null` for missing value.
Expand Down
4 changes: 2 additions & 2 deletions src/stencil/api.clj
Original file line number Diff line number Diff line change
Expand Up @@ -82,5 +82,5 @@
:else (throw (ex-info "Unexpected object to clean up!" {:template template})))
template)

(def version (or (System/getProperty "stencil-core.version")
(slurp (io/resource "stencil-version"))))
(def version (or (some-> (io/resource "stencil-version") slurp)
(System/getProperty "stencil-core.version")))
2 changes: 2 additions & 0 deletions src/stencil/functions.clj
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@
(defmethod call-fn "sum" [_ items]
(reduce + items))

(defmethod call-fn "list" [_ & elements] (vec elements))

(defmethod call-fn "hideColumn" [_ & args]
(case (first args)
("cut") (->HideTableColumnMarker :cut)
Expand Down
4 changes: 4 additions & 0 deletions test/stencil/functions_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@
(is (= nil (date "hu" "YYYY MMMM d", nil)))
(is (= nil (date nil "YYYY MMMM d", "2021-05-20"))))))

(deftest test-list
(is (= [] (call-fn "list")))
(is (= [1 nil 3] (call-fn "list" 1 nil 3))))

(deftest test-map
(testing "Empty input"
(is (= [] (call-fn "map" "x" [])))
Expand Down

0 comments on commit bf59ae8

Please sign in to comment.