Skip to content

Instantly share code, notes, and snippets.

@veered
Created May 21, 2017 21:07
Show Gist options
  • Save veered/6c1d3fd8404550d92b0fcd0a8aeecd0c to your computer and use it in GitHub Desktop.
Save veered/6c1d3fd8404550d92b0fcd0a8aeecd0c to your computer and use it in GitHub Desktop.
Reval plugin for BlazeJS
import Plugins from './plugins.js';
Plugins.add('BlazeJS', {
extensions: ['js'],
locations: ['client'],
compile({code}) {
let regex = /Template\.([a-z0-9]*?)\./gi,
templateNames = [],
match
;
while(match = regex.exec(code)) {
templateNames.push(match[1]);
}
_.unique(templateNames).forEach(templateName => {
code = `
if (Template['${templateName}']) {
Template['${templateName}'] = new Template('Template.${templateName}', Template['${templateName}'].renderFunction);
}
` + code;
});
return code;
},
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment