I'm using bleach
, which uses html5lib
to clean user-generated content that are HTML fragments designed as dust.js
templates
everything has worked fine, except for this situation-
input:
<table>
{#loop}
<tr>
<td>{name}</td>
</tr>
{/loop}
</table>
output:
{#loop}
{/loop}
<table>
<tr>
<td>{name}</td>
</tr>
</table>
the looping tags are being ordered outside of the table. this makes perfect sense - html5lib is correcting my html; content should not be within the table structure unless it's wrapped in a td/th tag. i usually want corrections like this to happen, and still want corrections to happen -- but am wondering if there is a way to somehow get these tags through.
has anyone encountered a similar situation in the past, and been able to suppress this sanitization behavior?
The only approach I've come up with so far, is to wrap the controls in a tag that I can regex out:
<table>
<tr data-layout=""><td>{#loop}</td></tr>
<tr>
<td>{name}</td>
</tr>
<tr data-layout=""><td>{/loop}</td></tr>
</table>
the problem with this approach, is that once I regex out this formatting hack, I can't easily build it back in. the encoded template becomes uneditable.