I ran into lots of problems when trying to implement this.
Basically <html>
tags were always stripped out and I couldn't find a way to access the html markup before the tags were stripped or to encode the html within the div containing the markup. jQuery's text()
and html()
and various combinations of them did not work.
Solution
This was the solution that eventually worked for me.
http://jsfiddle.net/rwone/rAFSZ/1/
HTML
<div id="my_html"></div>
<!-- this works using <xmp> tags and NOT when using <div> tags -->
<xmp id="my_html_hidden"><html>test</html></xmp>
jQuery
The approach I used was to set the value like this:
var html_editor = ace.edit("my_html");
// other editor settings
html_editor.session.setValue($("#my_html_hidden").text());
So the logic of this is that the content was loaded into a hidden div from the database, and then the value of the editor was set with the contents of this hidden div, with the text()
method applied.
The key was that using <xmp>
tags did NOT strip the <html>
tags, whereas using <div>
tags did.