Skip to content

Commit

Permalink
fix template exports
Browse files Browse the repository at this point in the history
  • Loading branch information
Nathan Reid committed Apr 12, 2016
1 parent ee0f36a commit d2c1513
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
5 changes: 4 additions & 1 deletion templating-tools/code-generation.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@ Template.__checkName(${nameLiteral});
Template[${nameLiteral}] = new Template(${templateDotNameLiteral}, ${renderFuncCode});
`;
if (! name.match(/^[^a-zA-Z_$]|[^0-9a-zA-Z_$]/))
code += `export { Template[${nameLiteral}] as ${name} };\n`;
code += `
const ${name} = Template[${nameLiteral}];
export { ${name} };
`;
else if (process.env.BLAZE_DEBUG === '1')
console.warn('Template ${name} cannot be exported because it is not a valid JavaScript variable name.');

Expand Down
3 changes: 2 additions & 1 deletion templating-tools/html-scanner-tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ Tinytest.add("templating-tools - html scanner", function (test) {
'] = new Template(' + viewName +
', (function() {\n var view = this;\n return ' + content + ';\n}));\n' +
(nameWithoutQuotes.match(/^[^a-zA-Z_$]|[^0-9a-zA-Z_$]/) ? '' :
'export { Template["' + nameWithoutQuotes + '"] as favoritefood };\n');
'\nconst ' + nameWithoutQuotes + ' = Template[' + templateName + '];\n' +
'export { ' + nameWithoutQuotes + ' };\n');
};

var simpleTemplateDefaultExport = function(templateName, content) {
Expand Down

0 comments on commit d2c1513

Please sign in to comment.