Created
May 21, 2017 21:07
-
-
Save veered/6c1d3fd8404550d92b0fcd0a8aeecd0c to your computer and use it in GitHub Desktop.
Reval plugin for BlazeJS
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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