GrapesJS / grapesjs

Free and Open source Web Builder Framework. Next generation tool for building templates without coding
https://grapesjs.com
BSD 3-Clause "New" or "Revised" License
22.38k stars 4.06k forks source link

[Question] How to integrate handlebars with GrapesJS? #938

Closed andre2 closed 6 years ago

andre2 commented 6 years ago

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?

artf commented 6 years ago

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

ondrejpolach commented 6 years ago

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

lock[bot] commented 5 years ago

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.