Is it a good idea to have/add logic inside a javascript template like so?
<time style="display: <%= time ? 'block' : 'none' %>"><%= time %></time>
How is rendering time affected by this? Is a it big difference?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
In general, it is wise to avoid logic in templates, although conditionally outputting a block if some value is initialized is ok.
The following, I would not have a problem with:
For your situation, I would do this. In your
<head>(or css):In your template:
I’m not certain about browser support for the `:empty´ pseudo-selector, but just to be safe you could also do: