javascript - TinyMCE converting > to > -


ok, have been looking while can gather there no option in tinymce disable characters being converted entities.

i can understand reason behind this, valid html nice, however, need way stop this, have email template editor client can edit there email templates , insert template variables (i.e. account::first()->first_name grabs first name of customer).

tinymce converting -> ->

is there anyway can prevent on tinymce side of things?

as said extensively in comments - makes no sense stop tinymce producing valid html, because results become unpredictable.

instead, de-html-ify template tags and them produce correct template:

function sanitizetemplate(content) {    var div = document.createelement('div');    return content.replace(/{{.*?}}/g, function(mustache) {      div.innerhtml = mustache;      return div.textcontent;    });  }    // var content = tinymce.activeeditor.getcontent();  content = "<p>dear {{ account::first()-&gt;first_name }}</p><p>thank not using &lt;script&gt; tags.</p>";    snippet.log("received editor:");  snippet.log(content);  var template = sanitizetemplate(content);  snippet.log("the fixed template:");  snippet.log(template);
<!-- provides `snippet` object, see http://meta.stackexchange.com/a/242144/134069 -->  <script src="http://tjcrowder.github.io/simple-snippets-console/snippet.js"></script>

note here not template tag still remains intact, , valid html (in particular, <script> user typed not magically become html tag , try executed).


Comments