-
Notifications
You must be signed in to change notification settings - Fork 156
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
attribute case is not preserved when converting from html #102
Comments
As you probably know tag and attribute names are case-insensitive in HTML and common convention is to use lower-case which got slipped into html2jade at some point for reasons I don't recall. I just checked Jade and it does preserve attribute name case. Since I don't want to introduce incompatibility with previous versions, I'll have to add an optional flag to preserve tag and attribute name case. Can you tell me why you need attribute names' case to be preserved so I can understand your use-case? |
angular2 template syntax needs this. On Monday, December 28, 2015, Don Park [email protected] wrote:
Prashant |
@pdeva it turns out lowercasing of attribute name is done at DOM layer before html2jade sees them which means html2jade will have to either use HTML parser directly or find a DOM implementation that preserves attribute name case. Unfortunately, neither options are pursuable time-wise. Punting for revisit later. |
Just remembered that Angular uses two forms for attributes: dashed (like ng-model) and camelcased (like ngModel), later form intended for use in JavaScript. Since I can't address this issue at this time, my suggested workaround is to write a short JS script that changes anything like "ngFoobar" to "ng-foobar". Sorry, this is the best I can do at this time. :-( |
the dashed form is no longer supported since angular2 beta Prashant On Mon, Dec 28, 2015 at 4:16 PM, Don Park [email protected] wrote:
|
do you have a link to an official doc saying that? I haven't been able to find any. - Don |
+1 Here is example from docs https://angular.io/docs/ts/latest/api/common/NgFor-directive.html Syntax
Selectors
I added failing test at tb@53e954b |
thx for the example @tb but as I wrote above html2jade uses DOM API to support client-side generated HTML and thus only sees DOM normalized lowercased attribute names so this functionality cannot be implemented without uprooting everything. When I get some spare time, I will look into htmlparser2, below DOM layer, which may expose the original attribute names and see whether it makes sense to switch or writing a completely new tool based on textual input makes more sense. |
Thanks for your work on this, @donpark, I'm also running into a case where tags and attribute name cases must be preserved.. on the fringe here :) |
Another use case — SVG names, like XML, are also case-sensitive. |
Another case is almost all react components are title cased |
+1 |
Hi all. I've noticed that jsdom now supports Thankfully, there is another relatively new module named html2pug and it appears to support case-sensitive conversion. |
Eg- this piece of code from a valid angular template becomes error prone when converted to jade cause
ngModel
is converted tongmodel
The text was updated successfully, but these errors were encountered: