I’m using a conditional in templating engine tinybutstrong to show a <div>
when a variable is not blank.
<div class="notice">[onshow;block=div;when [var.notice;noerr]!=''][var.notice;noerr]</div>
It works well except for when the $notice
variable has an apostrophe '
in it. Otherwise the onshow conditonal doesn’t run.
How do I fix this?
Advertisement
Answer
The values may have quotes, you have to use delimiters and escaping :
<div class="notice"> [onshow;block=div;when '[var.notice;strconv=esc;noerr]'!=''] [var.notice;noerr] </div>
The manual has been updated in order to have this clearer.
But is you case, using a magnet seems smarter:
<div class="notice"> [onshow.notice;noerr;magnet=div] </div>