Issue #2787💬 AnsweredOpened May 18, 2020by JoLoZ0 reactions

Replace all of HTML

快速解答by artf

Well a lot of things depend on your backend and there I can't help you, but if you need to replace the canvas with a new template you would use something like this

Read full answer below ↓

Question

Hello there, I am trying to use GrapesJS for template customization for my end users, but ran in the following problem: There is no documented way which I can replace all of the content with something like a function.

I tried redirecting, but that, well... redirects.

What I have: -An exact copy of the demo page (I couldn't get the main thing running yet, but it's good enough for testing.) -Static .html files where I pull the templates from -A small script that catches URL arguments and tries to replace the content with the file from the base parameter. -PHP 7.4 (Could also switch to a bunch of other versions, including PHP 5) -An external catalogue, which redirects the browser to the editor with the base parameter set.

The content is comming like this:

<body>
<p>Imagen some content here. Get creative!</p>
<style>
</style>
</body>

Answers (1)

artfJune 9, 2020

Well a lot of things depend on your backend and there I can't help you, but if you need to replace the canvas with a new template you would use something like this

editor.setComponents(`<p>Imagen some content here. Get creative!</p>
<style>
</style>`)

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.