Issue #2741💬 AnsweredOpened April 28, 2020by Joshmamroud0 reactions

How to wrap component with text nodes based on trait?

Quick answerby artf

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

Read full answer below ↓

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: Example 2: component with trait value would render like so: Also, I'd like to exclude the wrapper text nodes in example 2 from the view if possible. I've been working on thi...

Answers (2)

artfApril 29, 2020

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

JoshmamroudApril 29, 2020

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...

Free option

Check the open-source GrapesJS plugins on GitHub or run a quick search in our free catalog.

Browse free plugins →
Premium option

Premium plugins ship with support, regular updates, and production-ready features — save days of integration work.

Browse premium plugins →

Related tutorials

In-depth guides on the same topic.

All tutorials →

Browse Plugin Categories

Jump directly to plugin category pages on the marketplace.