[Question] How to integrate handlebars with GrapesJS?
Question
Hi,
How i can integrate handlebars or other template engine with GrapeJS?
I mean to create eg. dynamic component with product details:
const blockManager = editor.BlockManager;
blockManager.add("product", {
label: "Product",
type: "text",
attributes: { class: "fa fa-columns" },
content: `
<div>
<h2>{{product.name}}</h2>
<div>{{product.details}}</div>
</div>
`
});
And show parsed data in GrapeJS editor eg.
<div>
<h2>Sample product</h2>
<div>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque tristique molestie mi, a commodo quam cursus eget.</div>
</div>
But on export user must get raw data, i mean code with handlebars content.
Someone can help?
Answers (3)
Hi andre2, do you complete this solution for handlebars integration? can you share some code please?
You should create a custom Component which implements the template engine inside its view (eg. compile the template inside the render method)
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Related Questions and Answers
Continue research with similar issue discussions.
Issue #1831
[Question] How to run command for a block component?
I'd like to do something like this. so once a user drops the test component into the canvas, I'd like to open up asset manager modal where...
Issue #1574
Question, Block content from file
Hi, this is not really an issue but more a question. I'm currently using custom blocks in my GrapesJS editor. This is how I create them : I...
Issue #1545
[Question] How I Get ID From Block?
Hi, i have my block and I get print in Div id results from my javascript class component... How i get ID from my block ??? editor.BlockMana...
Issue #1706
[Question]: How to get href from rte?
I have this rte toolbar where you can type and click 'save' and it's going to create a link for the selected text. but the problem is that...
Paid Plugins That Match This Issue
Curated by issue keywords and label relevance to help you ship faster.
Loading paid plugin recommendations...
Browse Plugin Categories
Jump directly to plugin category pages on the marketplace.