Issue #1556Opened November 1, 2018by thanhpd560 reactions

Add new block to block manager: predefined content and editor content is different

Question

I try to use template engine with grapesjs. Add new block by this:

bm.add('promotion-lines', {
    label: 'Promotion Lines',
    category: c.labelCategory,
    attributes: {class: 'fa fa-list-ol'},
    content: `<ul>
  <table style="box-sizing: border-box; height: 150px; margin: 0 auto 0 auto; padding: 0 0 0 0; width: 100%;">
    <tbody style="box-sizing: border-box;"><tr style="box-sizing: border-box;">
     {% for order_line in order.order_lines %}
     <td style="box-sizing: border-box; padding: 0; margin: 0; vertical-align: top;" valign="top"/>
      {% endfor %}
    </tr>
    </tbody>
  </table>
</ul>`,
  });

Drag new block to editor then the content of editor is different from above: (the {% for order_line in order.order_lines %} is moved up)

<ul style="box-sizing: border-box;">
  {% for order_line in order.order_lines %}
  <table id="imf58" style="box-sizing: border-box; height: 150px; margin: 0 auto 0 auto; padding: 0 0 0 0; width: 100%;" width="100%" height="150">
    <tbody id="isbik" style="box-sizing: border-box;">
      <tr id="ikbcn" style="box-sizing: border-box;">
        <td valign="top" id="ipg0l" style="box-sizing: border-box; padding: 0; margin: 0; vertical-align: top;">
          {% endfor %}
        </td>
      </tr>
    </tbody>
  </table>
</ul>

How can i prevent this? Thanks.

Answers (2)

artfNovember 3, 20180 reactions

If you drop a not valid HTML structure it will be rearranged by the browser, you can't prevent it

lock[bot]November 3, 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.