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

Feature request: html templates support #2

Open
LeleDev opened this issue Sep 13, 2014 · 5 comments
Open

Feature request: html templates support #2

LeleDev opened this issue Sep 13, 2014 · 5 comments
Assignees
Labels

Comments

@LeleDev
Copy link

LeleDev commented Sep 13, 2014

I there! I'm expecting this problem...
Using angularjs I need to embed html templates like this:

<script id="dashboard.html" type="text/ng-template">
    // html content
<script>

Tidy process the html content it as if it would be javascript code instead of html (or 'ng-template')... could you fix this somehow? For example discriminating between "text/ng-template" and "text/javascript" strings...

Thank you in advance

@geoffmcl
Copy link
Owner

Hi Emanuele,

Well today is the first I had heard of 'angularjs' ;=))

But I have started to 'look' at it... interesting...

For now I have added the 'Feature' label to your post...

It does not seem like too much of a problem noting the
type/ng-template and treating the contents as html...

Tidy does very little to the content of a script...

But you mean if type/ng-template is noted the contents
should be treated as html text and relined, etc accordingly?

But I note a few other things, like -

triggers a warning of 'proprietary attribute'

<a ng-click="foo"... also warns 'proprietary'...

Do you have, or could you give me a full list of ALL the
ng-???? attributes, and hopefully that would include
what 'tags' can carry these additional attributes...

And so far I have scraped together a few very minimal
examples. It would be appreciated if you could give me
some more, particularly where this tidy5 fork does the
WRONG thing...

And hopefully explaining what yo expect.

Anyway, for sure I will continue to look into what it would
take to support this angualrjs feature request...

Regards,
Geoff.

@LeleDev
Copy link
Author

LeleDev commented Sep 14, 2014

Thank you very much!

Regarding the tidy of template sections, yes, you got it right. Consider that in my last app the 90% of the html code is inside template sections. And being them wrapped between script tags, tidy only finds javascript errors, like:

'<' + '/' letter not allowed here

skipping the the other html ones like

trimming empty <div>

Regarding ng-attributes istead, I'm not sure they must be excluded a priory because, if I recall correctly, they aren't still supported by the official html5 standards. To make them standard compliant it's simple: just put the data- attribute in front of them (with angular, at least)

@geoffmcl
Copy link
Owner

Hi Emanuele,

Re: ng-attributes

Not so sure about W3C 'official' position,
but do note that they have a tutorial on
AngularJS in the W3Schools...

And they have a page listing the AngularJS
Directives -
http://www.w3schools.com/angular/angular_ref_directives.asp
So they are certainly at least considering
it ;=))

And thanks for the information about adding
'data-' to the front of the ng-directives, and
tidy5 then accepts them without warnings...

But at the moment the one thing I can not find
in W3C tutorials is the -

<script type="text/ng-template"...? I can find many other examples of this here and there... And yes, I can see current tidy5 outputs the 'incorrect' warning - '<' + '/' + letter not allowed here And of course any re-lining of this section is as per javascript, and not as html5 content, including no 'fixes' to the html. Re: the tidy of template sections Ok, will try something, probably under a compile time flag like - ENABLE_ANGULARJS Just to keep it separate for now... And maybe add a configuration item like - --enable-angularjs:yes And maybe with a clear declaration of the intended doctype, like - --doctype:html5 But these are just initial thoughts... and may change as I get into it... which will be in a few days... Will bounce back when I have something for you to try... hopefully later in the week... I am assuming of course that you are compiling tidy5 from the git source, and are familiar with say adding a cmake option like -DENABLE_ANGULARJS:BOOL=ON Regards, Geoff.

@geoffmcl geoffmcl self-assigned this Sep 14, 2014
@LeleDev
Copy link
Author

LeleDev commented Sep 14, 2014

Thank, really, really kind!

I like and approve your solutions 👍

Here it is the official angular doc about templates (to be honest I couldn't find it on w3schools too):
https://docs.angularjs.org/api/ng/directive/script

@geoffmcl
Copy link
Owner

Unfortunately NOT so kind ;=()

Concerning the script templates, while I at
first thought it would be easy, it turned
out to be quite difficult ;=((

Inside the script handling I would have
to virtually repeat most of the tidy
html handling... quite a BIG change...

So, while I will think about it some more,
and leave the request open for now, it may
be too 'messy'... I will come back to it
now and again if I get another idea...

And further, to quote from another contributor -

"Just because they are named W3Schools does not
mean they are associated in any way with W3C.
Moreover their site is far from being a trustworthy
reference source. It is a site built for SEO."

That certainly reduced my initial enthusiasm...

And he added another idea about the 'proprietary'
attributes -

"My first guess is that, instead of micro-managing
third-party attributes, you should make it possible
for anyone to add custom attributes to the list of
valid items."

That seems a reasonable way to go, and will ponder
that a bit...

Sorry, this is not getting very far at this time...

Regards,
Geoff.

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

No branches or pull requests

2 participants