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

Add option to ignore templating tags #691

Open
maxnordlund opened this issue Mar 12, 2018 · 3 comments
Open

Add option to ignore templating tags #691

maxnordlund opened this issue Mar 12, 2018 · 3 comments

Comments

@maxnordlund
Copy link

maxnordlund commented Mar 12, 2018

After reading #310 I think an option to ignore templating tags would solve it along with any other templating language the user might have.

Taking the Jinja/Django example from that issue:

{% extends "layout.html" %}
{% block body %}
  <ul>
  {% for user in users %}
    <li><a href="{{ user.url }}">{{ user.username }}</a></li>
  {% endfor %}
  </ul>
{% endblock %}

If tidy could be, in this case, convinced to ignore {% .. %} and { ... } tags then it would parse correctly. Same goes for the popular mustaches syntax {{ ... }} and <% ... %> for ERB/EEX.

This is a more general solution, and is similar to the custom tags option that already exists. What do you think?

@geoffmcl
Copy link
Contributor

@maxnordlund this seems a repeat of closed #310, Nov, 2015, but maybe it is time to look again...

First tidy is a HTML linter, fixer, tidier, and not a template tool! It should only parse, fix, format [x]html...

Having said that, tidy does already handle things like <?, <%, <#, and more, ..., more or less as transparent text, so maybe there is a case for others to be handled better... perhaps under a new suitable option...

It has to be repeated with a config of --show-body-only yes --fix-uri no tidy already does quite well with the above sample input, added as in_691.html to my test repo...

All I can say at this point is that comments, patches, PR's would certainly be reviewed, and provided there were no adverse consequences to tidy's html parsing, considered for inclusion...

Look forward to further feedback... thanks...

@geoffmcl geoffmcl added this to the 5.7 milestone Mar 14, 2018
@maxnordlund
Copy link
Author

maxnordlund commented Mar 19, 2018

Not quite, it's about the general case and as such I do believe it should be in tidy. You're right that tidy mostly ignores templating languages, but there are places where it doesn't which generates false positives.

Those are when free text is not allowed, like table > tr > td and ul > li relationships. Unfortunately those are also the ones that commonly have loops, which means they generate a lot of noise when checked with tidy.

I agree that you should need the --show-body-only yes option, but URI that contain templating tags should be ignored as you can only know at runtime if the resulting URI is valid or not. For stuff like: <a href="{{ url_for 'index' }}">Home</a>.

In order to do this in a sane way, I suggest adding some sort of config for templating start/end tags that tidy matches, and completely ignores, --templating-tag-start "{" --templating-tag-end "}" maybe.

Does this make it clearer? What do you think about that type of option? (Name up to debate of course.)

@JESii
Copy link

JESii commented Apr 17, 2018

I think general support for handling templating tags {{handlebars-tags for me}} would make this even more useful/valuable. As @geoffmcl points out, you already support some templating tags <#such as erb> so why not the others? To my mind, it's no longer a philosophical issue, but an implementation issue. And thanks for for bringing this back to life!

@balthisar balthisar modified the milestones: 5.7, 5.9 Jul 9, 2021
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

4 participants