Best way to deal with <% %> in html template code.

I have code like this in a template that I want to load in a codeMirror textarea.

<div id="wrap">
	<p>
		<% if ( data ) { %>
		<span><%= data %></span>
		<% } %>
	</p>
</div>

If I set the mime type to text/html or text/javascript it says “Special characters must be escaped [ < ]”. When I set it to text, it works fine, but then I lose the color coding ( which I prefer to keep ).

I never used codeMirror before, and have tried to find a way to deal with this on Google / Stackoverflow / the documentation, but no luck so far.

If anyone can point me in the right direction of the recommended way to deal with this, then that would be great :slight_smile:

“Special characters must be escaped” is not an error message coming from CodeMirror, not does version 6 of CodeMirror use MIME types to configure the mode, so I’m not really sure what you are doing.