Reputation: 2939
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> </td>
<td> </td>
</tr>
{if empty($test)}
<tr>
<td> </td>
<td> </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> </td>
<td> </td>
</tr>
<tr>
<td> </td>
<td> </td>
</tr>
</tbody>
</table>
Upvotes: 1
Views: 2647
Reputation: 4585
Use html comments instead:
<table border="0">
<tbody>
<tr>
<td> </td>
<td> </td>
</tr>
<!-- {if empty($test)} -->
<tr>
<td> </td>
<td> </td>
</tr>
<!-- {/if} -->
</tbody>
</table>
Upvotes: 0
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
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