mirror of
https://gitlab.silvrtree.co.uk/martind2000/nci.git
synced 2025-01-11 06:25:07 +00:00
35 lines
638 B
JavaScript
35 lines
638 B
JavaScript
|
'use strict';
|
||
|
|
||
|
var through = require('through'),
|
||
|
jade = require('react-jade');
|
||
|
|
||
|
module.exports = function(fileName, options) {
|
||
|
if (!/\.jade$/i.test(fileName)) {
|
||
|
return through();
|
||
|
}
|
||
|
|
||
|
var template = '';
|
||
|
return through(
|
||
|
function(chunk) {
|
||
|
template += chunk.toString();
|
||
|
},
|
||
|
function() {
|
||
|
options.filename = fileName;
|
||
|
options.globalReact = true;
|
||
|
|
||
|
try {
|
||
|
template = jade.compileClient(template, options);
|
||
|
} catch (e) {
|
||
|
this.emit('error', e);
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
var moduleBody = 'var React = require("react");\n' +
|
||
|
'module.exports = ' + template;
|
||
|
|
||
|
this.queue(moduleBody);
|
||
|
this.queue(null);
|
||
|
}
|
||
|
);
|
||
|
};
|