Skip to content

Commit

Permalink
htmlOutputTemplate bug
Browse files Browse the repository at this point in the history
After moving from 4.x to 5.1 I noticed that the html template stopped working. I pulled down the source and tracked down the issue. It looks like htmlOutputTemplate was missing from the delayTemplateExpansion array and grunt would replace the placeholders as it would try and resolve them (so your generated html.ts files would not have the html content). I looked to add a test but it looks like one was added but not being run correctly (it needed the html settings within the options object and the settings and expected template needed some tweaks to get the diff passing. As I was preparing this pull request I noticed someone else had also picked up on this issue as well.
  • Loading branch information
johnman committed Nov 6, 2015
1 parent 92af2e6 commit 0c28844
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 14 deletions.
17 changes: 9 additions & 8 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -637,15 +637,16 @@ module.exports = function (grunt) {
},
test_htmlOutputTemplate: {
test: true,
options: {},
options: {
htmlVarTemplate: 'html',
htmlModuleTemplate: 'html.external',
htmlOutputTemplate:'module <%= modulename %> {\n' +
' export var <%= varname %> = \'<%= content %>\';\n' +
'}\n'
},
html: 'test/htmlExternal/**/*.html',
src: 'test/htmlExternal/**/*.ts',
htmlVarTemplate: 'markup',
htmlModuleTemplate: 'html',
htmlOutputTemplate: '/* tslint:disable:max-line-length */ \n' +
'export module <%= modulename %> {\n' +
' export var <%= varname %> = \'<%= content %>\';\n' +
'}\n'
src: 'test/htmlExternal/**/*.ts'

},
decoratorMetadataPassed: {
test: true,
Expand Down
2 changes: 1 addition & 1 deletion tasks-internal/modules/optionsResolver.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion tasks-internal/modules/optionsResolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const propertiesFromTarget = ['amdloader', 'html', 'htmlOutDir', 'htmlOutDirFlat
'mapRoot', 'module', 'newLine', 'noEmit', 'noEmitHelpers', 'noEmitOnError', 'noImplicitAny', 'noResolve',
'preserveConstEnums', 'removeComments', 'sourceRoot', 'sourceMap', 'suppressImplicitAnyIndexErrors', 'target',
'verbose', 'jsx', 'moduleResolution', 'experimentalAsyncFunctions', 'rootDir'],
delayTemplateExpansion = ['htmlModuleTemplate', 'htmlVarTemplate'];
delayTemplateExpansion = ['htmlModuleTemplate', 'htmlVarTemplate','htmlOutputTemplate'];

let templateProcessor: (templateString: string, options: any) => string = null;
let globExpander: (globs: string[]) => string[] = null;
Expand Down
2 changes: 1 addition & 1 deletion tasks/modules/optionsResolver.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion tasks/modules/optionsResolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const propertiesFromTarget = ['amdloader', 'html', 'htmlOutDir', 'htmlOutDirFlat
'mapRoot', 'module', 'newLine', 'noEmit', 'noEmitHelpers', 'noEmitOnError', 'noImplicitAny', 'noResolve',
'preserveConstEnums', 'removeComments', 'sourceRoot', 'sourceMap', 'suppressImplicitAnyIndexErrors', 'target',
'verbose', 'jsx', 'moduleResolution', 'experimentalAsyncFunctions', 'rootDir'],
delayTemplateExpansion = ['htmlModuleTemplate', 'htmlVarTemplate'];
delayTemplateExpansion = ['htmlModuleTemplate', 'htmlVarTemplate', 'htmlOutputTemplate'];

let templateProcessor: (templateString: string, options: any) => string = null;
let globExpander: (globs: string[]) => string[] = null;
Expand Down
3 changes: 1 addition & 2 deletions test/expected/htmlExternal/html.external.html.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* tslint:disable:max-line-length */
module html.external {
export var html = '<div> This is an HTML file that we want to compile to a TypeScript external module.</div>';
export var html = '<div> This is an HTML file that we want to compile to a TypeScript external module.</div>';
}

1 comment on commit 0c28844

@johnman
Copy link
Contributor Author

@johnman johnman commented on 0c28844 Nov 6, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any chance of checking the changes and pushing a new patch release to npm?
Thanks!

Please sign in to comment.