Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Preserve case to support angular directive attributes #897

Closed
squaretabledev opened this issue Aug 7, 2020 · 4 comments
Closed

Preserve case to support angular directive attributes #897

squaretabledev opened this issue Aug 7, 2020 · 4 comments
Milestone

Comments

@squaretabledev
Copy link

We are trying to parse multiple angular html template files in order to quickly extract translatable
content. The directives for example "*ngIf", "*ngFor" are transformed to "*ngif" and "*ngfor" and then
the template is broken after save.

Would it be possible to extend or modify the parser so that the attribute case remains unchanged.

It seems that I might be able to do this using a CustomHtmlMarkupFormatter and overriding the
Attribute behavior.

Is this correct?

The other issue I have is if I do AddAttribute with a "*ngIf", the method complains that the * is a invalid
character. I have a hacky way to get around this but is there possibly a more elegant way to solve this?

@FlorianRappl
Copy link
Contributor

Would it be possible to extend or modify the parser so that the attribute case remains unchanged.

The parser follows the spec - and the spec normalizes attributes. This is the same behavior the browser shows.

It seems that I might be able to do this using a CustomHtmlMarkupFormatter and overriding the
Attribute behavior.

The formatter only formats. It does not parse. It cannot infer what the original name was. Maybe its enough for you - then yes, but from the first paragraph I thought you already want to change the parsing perspective.

@squaretabledev
Copy link
Author

squaretabledev commented Aug 7, 2020

Hi thanks for getting back to me so quickly. You are correct. I need to parse from the original so the MarkupFormatter will not work for me unless I take every possible directive and fix the case but not all directives are known in advance.

I am assuming there are no extension points to the parser like there are for the MarkupFormatter?

@FlorianRappl
Copy link
Contributor

I am assuming there are no extension points to the parser like there are for the MarkupFormatter?

Yeah - at least not as with the IMarkupFormatter. There are, however, various points of configuration (see the parser options). Maybe we could add something here.

@FlorianRappl
Copy link
Contributor

Landed in devel.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants