Skip to content

Using capitalize in a template #158

Answered by mattiasb
mattiasb asked this question in Q&A
Discussion options

You must be logged in to vote

If I use (p "" str) over (s str) the template works fine.

Wild guess: The s element will bind NAME in (str NAME) to
nil instead of "" when the field is empty. This means that
(capitalize str) in my template will error out before I get to
type anything.

If that's the case the following template should work:

(example ";;" (capitalize (or str ""))
         n (s str))

And the reason the make-string calls in example2 works is
because nil is the empty list so (length nil) is 0 and not
a failure.

And now I've just tested this and it's indeed the case.

Now, I can't think of a case where I would want (s NAME) to
bind NAME to nil over "" when the field is empty and it's
a source of confusion and b…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by mattiasb
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant