railsTemplate.js 436 B

12345678910111213141516171819202122
  1. /**
  2. * Strips the rails template tags from a js.erb file
  3. *
  4. * @module plugins/railsTemplate
  5. */
  6. 'use strict';
  7. exports.handlers = {
  8. /**
  9. * Remove rails tags from the source input (e.g. <% foo bar %>)
  10. *
  11. * @param e
  12. * @param e.filename
  13. * @param e.source
  14. */
  15. beforeParse: function(e) {
  16. if (e.filename.match(/\.erb$/)) {
  17. e.source = e.source.replace(/<%.*%>/g, '');
  18. }
  19. }
  20. };