Skip to content

Commit

Permalink
fix(compiler): allow single quotes into named interpolations (angular…
Browse files Browse the repository at this point in the history
  • Loading branch information
ocombe authored and sjtrimble committed Mar 25, 2017
1 parent 1230ce5 commit 4075ef8
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
5 changes: 3 additions & 2 deletions packages/compiler/src/i18n/i18n_parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -161,8 +161,9 @@ class _I18nVisitor implements html.Visitor {
}
}

const _CUSTOM_PH_EXP = /\/\/[\s\S]*i18n[\s\S]*\([\s\S]*ph[\s\S]*=[\s\S]*"([\s\S]*?)"[\s\S]*\)/g;
const _CUSTOM_PH_EXP =
/\/\/[\s\S]*i18n[\s\S]*\([\s\S]*ph[\s\S]*=[\s\S]*("|')([\s\S]*?)\1[\s\S]*\)/g;

function _extractPlaceholderName(input: string): string {
return input.split(_CUSTOM_PH_EXP)[1];
return input.split(_CUSTOM_PH_EXP)[2];
}
6 changes: 6 additions & 0 deletions packages/compiler/test/i18n/i18n_parser_spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,12 @@ export function main() {
.toEqual([
[['[before, <ph name="TEST"> exp //i18n(ph="teSt") </ph>, after]'], 'm', 'd'],
]);

expect(
_humanizeMessages('<div i18n=\'m|d\'>before{{ exp //i18n(ph=\'teSt\') }}after</div>'))
.toEqual([
[[`[before, <ph name="TEST"> exp //i18n(ph='teSt') </ph>, after]`], 'm', 'd'],
]);
});
});

Expand Down

0 comments on commit 4075ef8

Please sign in to comment.