ynh
ynh

Reputation: 2939

Disable TinyMCE auto clean up

I want to use the tinymce editor to edit smarty templates. The problem is that the editor always rearrange the code. If I enter this code in to the HTML window:

<table border="0">
<tbody>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
{if empty($test)}
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
{/if}
</tbody>
</table>

turns into this code after clicking the OK button:

<p>{if empty($test)} {/if}</p>
<table border="0">
<tbody>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
</tbody>
</table>

Upvotes: 1

Views: 2647

Answers (3)

vimdude
vimdude

Reputation: 4585

Use html comments instead:

<table border="0">
<tbody>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
<!-- {if empty($test)} -->
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
<!-- {/if} -->
</tbody>
</table>

Upvotes: 0

&#193;lvaro Gonz&#225;lez
&#193;lvaro Gonz&#225;lez

Reputation: 146450

I've never written one but I presume that JavaScript-powered HTML editors don't work directly on HTML. Instead, they probably build a DOM tree in memory. You are not working on plain HTML but on Smarty code. That means that you'll always lose information if you handle it as HTML since it's not such thing. The example you give illustrates it pretty well: there is no way to represent that string as HTML; if you open it inside a browser, it will look broken.

The plain fact is that visual HTML editors are designed to edit HTML. Smarty templates only resemble HTML.

Upvotes: 2

Thariama
Thariama

Reputation: 50832

All text needs to be inside a html container - usually a p-tag. That is the reason why

{if empty($test)}

transforms to

<p>{if empty($test)} {/if}</p>

. You may choose to wrap this code inside a tag of your choice, but it needs to be inside an element!

Upvotes: 1

Related Questions