Issue #2741Opened April 28, 2020by Joshmamroud0 reactions

How to wrap component with text nodes based on trait?

Question

Hello @artf ,

I'm not sure if this goes here but I can't figure out from the documentation how to update the component model based on a trait.

The functionality I'm trying to achieve is add a text trait to a component called "condition" which would accept a Boolean expression. If this trait has a value then I would like to wrap the component with a text node like so:

Example 1

component without trait would render like so:

<p>Some content in here</p>

Example 2:

component with trait value would render like so:

{if TRAIT_VALUE }
<p>Some content in here</p>
{endif}

Also, I'd like to exclude the wrapper text nodes in example 2 from the view if possible.

I've been working on this for days but feel like everything I try is a hack. In your opinion, what is the best way to do this?

Thank you! Josh

Answers (2)

artfApril 29, 20200 reactions

You just have to extend the toHTML function of the component model to achieve it (search in issues if you need examples)

JoshmamroudApril 29, 20200 reactions

Ok, I will take a look. Thank you!

Related Questions and Answers

Continue research with similar issue discussions.

Paid Plugins That Match This Issue

Curated by issue keywords and label relevance to help you ship faster.

View all plugins

Loading paid plugin recommendations...

Browse Plugin Categories

Jump directly to plugin category pages on the marketplace.