Grapesjs: [Question] How to integrate handlebars with GrapesJS?

Created on 8 Mar 2018  路  3Comments  路  Source: artf/grapesjs

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?

outdated

Most helpful comment

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

All 3 comments

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

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

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.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

FlashPapa picture FlashPapa  路  3Comments

ionic666 picture ionic666  路  3Comments

SylvainBigonneau picture SylvainBigonneau  路  3Comments

adam-gpc picture adam-gpc  路  3Comments

tribulant picture tribulant  路  3Comments