Issue #938Opened March 8, 2018by andre25 reactions

[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)

ondrejpolachApril 17, 20185 reactions

Hi andre2, do you complete this solution for handlebars integration? can you share some code please?

artfMarch 9, 20180 reactions

You should create a custom Component which implements the template engine inside its view (eg. compile the template inside the render method)

lock[bot]September 17, 20190 reactions

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.

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.