Vulcan/packages/telescope-lib/lib/client/template_replacement.js
Gary Tierney 13e988dfec Add custom template prefix on client + server
Seperate template replacement from adding the initial "custom" prefix,
so that server-side templates (namely e-mails) can also have overrides.
2015-10-05 23:15:26 +01:00

20 lines
606 B
JavaScript

Meteor.startup(function () {
// loop over custom prefixes
Telescope.config.customPrefixes.forEach(function (prefix) {
// for each prefix, loop over all templates to find any replacements
Template.forEach(function (template) {
var templateName = template.viewName.replace("Template.", "");
// if current template name starts with the prefix, find original template and replace it
if (templateName.slice(0,prefix.length) === prefix) {
var oldTemplate = templateName.slice(prefix.length);
template.replaces(oldTemplate);
}
});
});
});