Search code examples
javascriptruby-on-rails-3eco

Eco JavaScript templates in Rails without duplicate code?


I am using 'eco' gem with my Rails application to load Eco templates. The templates are really handy and automatically loaded by Rails 3.1 asset pipeline. The only problem is that each .js file generated by eco includes the same javascript code that mainly deals with html escaping. The code is about 1.5K in non-minified form. It may become significant overhead if application uses a lot of templates (like a hundred of them). Is there a way to take this code out of the js files and include only once?


Solution

  • See gist https://gist.github.com/2043682 , I have extracted out the common part.