HubDB - if statements for empty - rich-text - fields

Dallas_Antwerp
Contributor

In hudDB 'rich-text' fields still output a '<p></p>' tag, even if the field has no value.

 

Let's say you have a title and sub-text you get from hubDB:
Schermafbeelding 2017-01-12 om 10.46.12.png

If the field '_text' has no value, the html markup will still look like this on the front-end:
Schermafbeelding 2017-01-12 om 10.49.48.png

 

Notice the empty '<p></p>' tag.

Solution

If you want to check rich-text fields for emty values, you can use this if statement:

Schermafbeelding 2017-01-12 om 10.53.13.png

 

If the rich-text field has no value, nothing will render.

 

Greetings

3 Replies 3
boulter
HubSpot Product Team

The HubDB table editor always wraps values in p tags. It seems to do this even when the content is empty. If you haven't edited the rich text value, it will be blank, so your test would have to check both the empty string and '<p></p>'.

 

In any case, we'll fix this behavior.

Dallas_Antwerp
Contributor

That would be great.

Could you alsow add a 'view source' button for a rich-text field?
(sometimes a client will want to add a <br> tag or something to the content.)

Thanks

boulter
HubSpot Product Team

The rich text editor is intentionally very restrictive, so a view source mode wouldn't allow you to paste in custom html. Option-return should allow you to insert vertical space though.

0 Upvotes