R
R
retyui2015-04-24 01:15:34
JavaScript
retyui, 2015-04-24 01:15:34

Shortening JADE templating code?

if user.familyName
    input.txt#familyName(type="text",value="#{user.familyName}" name="familyName" ,required ,placeholder="Введите Фамилию")
else
    input.txt#familyName(type="text",name="familyName" ,required ,placeholder="Введите Фамилию")

And there can be many more such checks
. How can I more gracefully shorten the above code?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
K
Konstantin Kitmanov, 2015-04-24
@retyui

input.txt#familyName(value="#{user ? user.familyName : ''}", type="text", name="familyName", required, placeholder="Введите Фамилию")

Well, for more serious things - mixins make it great not to write the same thing ten times.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question