feat(compiler): Introduce InterpolationConfig into component#9158
feat(compiler): Introduce InterpolationConfig into component#9158lacolaco wants to merge 1 commit intoangular:masterfrom
Conversation
|
I'm not sure whether that config works well on the offline compiler because I don't know how to test it... |
|
33a7c54 to
ba2b1bc
Compare
There was a problem hiding this comment.
interpolation: ['{{', '}}'] ?
There was a problem hiding this comment.
Oops, here should be new InterpolationConfig('{{', '}}') .
I think array is not type-safe. TypeScript cannot restrict that array's length.
There was a problem hiding this comment.
Static checking with Class/Interface vs Runtime checking with compMeta.interpolation.length == 2
Which makes more sense?
There was a problem hiding this comment.
We can not instantiate objects in decorators, otherwise they are not statically analyzable. The current version works fine because your object has the same interface as InterpolationConfig (TS uses structural type checking) but IMO is too verbose.
You can use an Array and check the length in the Component ctor
There was a problem hiding this comment.
I see. I'll do that. 👍
|
Great work on this PR ! I think you miss |
5a2052f to
5930d00
Compare
|
@vicb Thank you for reviewing! I wrote following tests at html_lexer_spec.ts it('should parse interpolation', () => {
expect(tokenizeAndHumanizeParts('{{ a }}')).toEqual([
[HtmlTokenType.TEXT, '{{ a }}'], [HtmlTokenType.EOF]
]);
expect(tokenizeAndHumanizeParts('{% a %}', null, {startSymbol: '{%', endSymbol: '%}'}))
.toEqual([[HtmlTokenType.TEXT, '{% a %}'], [HtmlTokenType.EOF]]);
});Either case, the result is In template_parser_spec, I could know that well via expect(humanizeTplAst(parser.parse(component, '{%a%}', [], [], 'TestComp'))).toEqual([
// unparser doesn't know interpolation config. check only AST type.
[BoundTextAst, '{{ a }}']
]);Can I check html_lexer as well as template_parser? |
|
Sorry for the delay, I'll try to check your PR by EOW. Could you please rebase ? Thanks |
|
I have added some comments. Could you please add some integration test. It would be have to have nested and sibling component with a different config (also length should be different, ie not 2 and start vs end). Thanks ! |
5930d00 to
a36ec80
Compare
|
A few comments but your work is very good and we can probably merge early next week. You can squash the current commits. Thanks, a few people have tried to implement this but haven't completed - including myself :) |
|
@vicb Thanks a lot, Victor. I really appreciate your kind help! |
There was a problem hiding this comment.
Can I use for...of statement? (thinking about ts2dart)
|
I thought we need to be careful about ts2dart transformation for |
If the tests pass you're fine |
|
Is the remaining issue linked to api guardian not being updated ? Please squash your commits. Thanks again for your great work. |
3565e8a to
892f44f
Compare
|
@vicb I think so. Thanks. |
|
I've squashed commits in 892f44f |
|
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
Please check if the PR fulfills these requirements
What kind of change does this PR introduce? (Bug fix, feature, docs update, ...)
What is the current behavior? (You can also link to an open issue here)
Interpolation symbols are defined as const
INTERPOLATION_REGEXP.This is not friendly to collaboration with other templating engines. (e.g. Python jinja)
What is the new behavior?
ComponentMetadata has a new property,
interpolation, which has start/end symbols for interpolation.Does this PR introduce a breaking change?
If this PR contains a breaking change, please describe the impact and migration path for existing applications: ...
Other information:
This is re-implementation from #8906
cc/ @vicb