Search code examples
javascriptckeditornvelocity

What WYSIWYG editor works with Velocity templates?


I've been working with (the excellent) CKeditor for a while, however when I started combining it with NVelocity I started to run into trouble. It turns out if I use a context keyword (say $GarbagePailKids which includes HTML of table rows) like this:

<table>
  <tbody>$GarbagePailKids</tbody>
</table>

The WYSIWYG mode of CKEditor corrects the invalid HTML into:

$GarbagePailKids
<table>
  <tbody></tbody>
</table>

Now everything I've been reading suggests that you don't (or can't) turn off CKeditor's ability to correct invalid HTML, and I would hate to switch back to just a textarea (after spoiling my users for so long with this editor). Any ideas on something like CKEditor that does work or even a plugin for CKEditor that prevents this behavior?


Solution

  • Try this:

    #set( $openComment = "<!--" )
    #set( $closeComment = "-->" )
    <table>
      <tbody>
          <!-- begin of rows $closeComment $GarbagePailKids $openComment end of rows -->
      </tbody>
    </table>
    

    If $GarbagePailKids is like this:

    <tr>
      <td>A</td>
    </tr>
    <tr>
      <td>B</td>
    </tr>
    

    The result is:

    <table>
      <tbody>
        <!-- begin of rows -->
        <tr>
          <td>A</td>
        </tr>
        <tr>
          <td>B</td>
        </tr>
        <!-- end of rows -->
      </tbody>
    </table>