0

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?

desbest
  • 4,746
  • 11
  • 51
  • 84

1 Answers1

1

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>
Skrol29
  • 5,402
  • 1
  • 20
  • 25