verbb / vizy

A flexible visual editor for Craft CMS
Other
44 stars 8 forks source link

Content disappears after saving #28

Closed jan-dh closed 3 years ago

jan-dh commented 3 years ago

Description

I made a plain text block to output some twig code in a blog post and style it with prism.js The content of the block is something like this:

{% for row in entry.tableField %}
  {% if loop.index == 1%}
  <thead>
    <tr>
      <th scope="col">{{row.col1}}</th>
      {% for i in 2..(tableSize) %}
        {% set colName = "col" ~ i %}
        {% set colValue = attribute(row, colName) %}
        {% set labelName = 'label' ~ i %}
        {% set emptyObject = emptyObject|merge({(labelName): (colValue)}) %}
        <th scope="col">{{colValue}}</th>
      {% endfor %}
    </tr>
  </thead>
  <tbody>
  {% else %} 

After saving the block and reloading the entry the content is gone:

image

image

I also get two errors from a vue file:

ReferenceError: attribute is not defined and vue.js?v=1621609911:6 ReferenceError: row is not defined

My guess would be that the unclosed {% else %} tag creates some issues when saving this field. I'm assuming it does get parsed somewhere before save, even though it's just a plain text field

Steps to reproduce

  1. Create a code block with a plain text field
  2. Copy the code snippet I posted above and save the entry
  3. Reload the page

Additional info

engram-design commented 3 years ago

Ah, good point here, because we're using Vue, it's trying to parse that as Vue template code - not what we want at all.

Fixed for the next release. To get the fix early, change your verbb/vizy requirement in composer.json to:

"require": {
  "verbb/vizy": "dev-craft-3 as 1.0.2",
  "...": "..."
}

Then run composer update.

engram-design commented 3 years ago

Fixed in 1.0.3