Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add default empty string arg and add capitalize func #15

Merged
merged 2 commits into from
Oct 27, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -540,6 +540,8 @@ To be written.

### toUpperCase(s)

### capitalize(s)

### range(begin, end, step)

### flatten(array)
Expand Down
69 changes: 69 additions & 0 deletions spec/functions_spec.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,15 @@ tests:
result:
first: ["foo", "bar", "baz"]


- desc: splitStr
scope:
s: null
template:
first: $ splitStr(s, " +")
result:
first: [""]

- desc: splitStr with limit = 0

scope:
Expand Down Expand Up @@ -94,3 +103,63 @@ tests:
a: "Hello JUTE mapping tool !"
b: ""
c: ""

- desc: toLowerCase
scope:
a: "HELLO"
b: ""
c: null
d: "Test"

template:
a: $ toLowerCase(a)
b: $ toLowerCase(b)
c: $ toLowerCase(c)
d: $ toLowerCase(d)

result:
a: "hello"
b: ""
c: ""
d: "test"

- desc: toUpperCase
scope:
a: "HELLO"
b: ""
c: null
d: "Test"

template:
a: $ toUpperCase(a)
b: $ toUpperCase(b)
c: $ toUpperCase(c)
d: $ toUpperCase(d)

result:
a: "HELLO"
b: ""
c: ""
d: "TEST"

- desc: capitalize
scope:
a: "HELLO"
b: ""
c: null
d: "Test"
e: "one"

template:
a: $ capitalize(a)
b: $ capitalize(b)
c: $ capitalize(c)
d: $ capitalize(d)
e: $ capitalize(e)

result:
a: "Hello"
b: ""
c: ""
d: "Test"
e: "One"
7 changes: 4 additions & 3 deletions src/jute/core.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@
(def standard-fns
{:join str/join ;; deprecated
:joinStr str/join
:splitStr (fn [s re & [limit]] (str/split s (re-pattern re) (or limit 0)))
:splitStr (fn [s re & [limit]] (str/split (or s "") (re-pattern re) (or limit 0)))
:substring subs ;; deprecated
:substr subs
:replace (fn [s re to]
Expand All @@ -126,8 +126,9 @@
:range range
:randNth rand-nth
:toString to-string
:toLowerCase str/lower-case
:toUpperCase str/upper-case
:toLowerCase #(str/lower-case (or % ""))
:toUpperCase #(str/upper-case (or % ""))
:capitalize #(str/capitalize (or % ""))
:toKeyword keyword
:hash hash
:toInt (fn [v] (if (string? v)
Expand Down