railsTemplate.js 411 B

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