index.js 808 B

12345678910111213141516171819202122232425
  1. /*globals module*/
  2. var escapeString = function (str) {
  3. 'use strict';
  4. return str.replace(/'/g, '\\\'').replace(/\r?\n/g, '\\n\' +\n \'');
  5. };
  6. var createPreprocessor = function (logger, basePath) {
  7. 'use strict';
  8. return function (content, file, done) {
  9. var path = file.originalPath.replace(basePath + '/', ''),
  10. filename = path.replace('.str', '');
  11. file.path = file.path + '.js';
  12. done("window.__mxl__ = window.__mxl__ || {};\nwindow.__mxl__['" +
  13. // filename + "'] = '" + escapeString(content) + "';\n"
  14. filename + "'] = window.atob('" + content + "');\n"
  15. );
  16. };
  17. };
  18. createPreprocessor.$inject = ['logger', 'config.basePath'];
  19. module.exports = {
  20. 'preprocessor:mxl2js': ['factory', createPreprocessor]
  21. };