0

I'm trying to figure out how to do an inline if statement:

div(class="social-text").
  #[b #{share.title}] #{share.bodyText}

In the code above it's possible that share.title=undefined. In case it is, I don't want to render a <b></b> tag in the resulting html but can't figure out how that works in pug.

Xen_mar
  • 8,330
  • 11
  • 51
  • 74
  • Does this answer your question? [How can I render inline JavaScript with Jade / Pug?](https://stackoverflow.com/questions/5858218/how-can-i-render-inline-javascript-with-jade-pug) – Freestyle09 May 26 '22 at 09:47
  • 1
    @Freestyle09 that's not related to this question – Sean May 26 '22 at 13:52
  • 1
    @Freestyle09 - no, not really. This one is about inline pug, not inline javascript ... :) – Xen_mar May 26 '22 at 17:00

1 Answers1

1

This is simpler to write if you don't use the block in a tag syntax after the initial div. You could write it like this instead, using a standard conditional and piped text:

div.social-text
  if (share.title !== undefined)
    b #{share.title}
  |  #{share.bodyText}
Sean
  • 6,873
  • 4
  • 21
  • 46