Search code examples
javascriptelrte

How do i tell elRte to not replace/mess my Tenjin tags?


When i'm inserting code like:

<?rb some_enumerator.each do |item| ?>
#{ item.name }
<?rb end ?>

it is replaced by:

<!--?rb some_enumerator.each do |item| ?-->
#{ item.name }
<!--?rb end ?-->

any opts to prohibit this?


Solution

  • You need custom restore callback in your opts.

    Something like this:

    var opts = {
      restore : [function(html) {
        return html.replace(/<!--\?rb\s+([^>]+)\s+\?-->/gi, function(t, statement) {
          return "<?rb " + statement + " ?>";
        });
      }]
    }
    
    $('your-selector').elrte(opts);
    

    elRte will still replace your tags but you'll fix them back via retore callback.