-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathindex.js
More file actions
23 lines (17 loc) · 741 Bytes
/
index.js
File metadata and controls
23 lines (17 loc) · 741 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
const loaderUtils = require('loader-utils');
const hamlc = require('haml-coffee');
module.exports = function(source) {
this.cacheable && this.cacheable(true);
const defaultOptions = {
escapeHtml: false
};
const loaderOptions = Object.assign({}, defaultOptions, loaderUtils.getOptions(this));
const loaderParams = Object.assign({}, defaultOptions,loaderUtils.parseQuery(this.resourceQuery || '?'));
// query params have priority over loader options as they are more granular
const options = Object.assign({}, loaderParams, loaderOptions)
const template = hamlc.template(source, null, null, {
placement: 'standalone',
escapeHtml: options.escapeHtml
});
return `module.exports = ${template.toString()}`;
}