Issue #2801πŸ’¬ AnsweredOpened May 25, 2020by fedd1 reactions

Enrich any component with the serverside if or foreach expressions (namely, MVEL)

Quick answerby Ju99ernaut❀ 1

To surround an element take look at toHtml, you can search it in the issues for examples. In any case I don't think it's a good idea to replace the default component type, I'd suggest creating a new component that extends the default type and using isComponent to determine how it is assigned. The docs for components m...

Read full answer below ↓

Question

I am researching how to make a template with server side expressions that will repeat a component (foreach) or completely remove it (if). My backend parses templates with mvel. What I am thinking is to add a couple of settings to all or some select elements. For example, to a <div> of a Cell, so it looks like this: <div mvel-foreach="item : people" class="cell" id="iuck"> ....some content dropped inside...@{item.lastName}... ...etc etc </div> Or to a Text (mvel-ending inserts separator between items): <div mvel-ending="', '" mvel-foreach="item : people" id="iohm">@{item.lastName}</div> After...

Answers (3)

Ju99ernautβ€’ May 26, 2020

To surround an element take look at toHtml, you can search it in the issues for examples. In any case I don't think it's a good idea to replace the default component type, I'd suggest creating a new component that extends the default type and using isComponent to determine how it is assigned. The d...

feddβ€’ May 26, 2020

The docs for components might be helpful I've written my code based on this article. It says,Updating component types is quite easy, let's see how: .... // The defaults property is handled differently // and will be merged with the old defaults So I am updating, not the default, but a simple "input...

artfβ€’ May 26, 2020

@fedd you can add your new traits in model.init function

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 β†’

Browse Plugin Categories

Jump directly to plugin category pages on the marketplace.