seitime-frappe/frappe-html-plugin.js
Faris Ansari 92e8856588
New Build System: Rollup (#5010)
* JS build working

* Css build working!

* Uglify JS in production

* fix codacy

* Add frappe.commands.popen

* FIx ESLint errors

* Add socket.io to package.json

* ignore subprocess warnings

* Add babel-runtime

* sleep 20 after bench start

* remove set -e

* [FIX] non-shell subprocess call

* [FIX] use shell = False

* split commands
2018-02-20 13:47:48 +05:30

26 lines
No EOL
591 B
JavaScript

const path = require('path');
function scrub_html_template(content) {
content = content.replace(/\s/g, ' ');
content = content.replace(/(<!--.*?-->)/g, '');
return content.replace("'", "\'"); // eslint-disable-line
}
module.exports = function frappe_html() {
return {
name: 'frappe-html',
transform(code, id) {
if (!id.endsWith('.html')) return null;
var filepath = path.basename(id).split('.');
filepath.splice(-1);
var key = filepath.join(".");
var content = scrub_html_template(code);
return `
frappe.templates['${key}'] = '${content}';
`;
}
};
};