Giter VIP home page Giter VIP logo

Comments (7)

yaegassy avatar yaegassy commented on July 18, 2024 1

I'm also interested in the jinja2, django template formatter.

It seems that there is a package called "vsot", but unfortunately it is not maintained.

PRE-APLHA, mostly unmaintained

(Something, if it would be helpful.)

Of course, if there is a dedicated plugin for prettier, I'm sure that's fine.

from curlylint.

yaegassy avatar yaegassy commented on July 18, 2024 1

@thibaudcolas I recently discovered a tool called djhtml. It appears to be actively being developed now.

DjHTML is an indenter and not a formatter

Currently, the feature seems to be only for indent adjustment, but we can expect more in the future.

from curlylint.

thibaudcolas avatar thibaudcolas commented on July 18, 2024 1

@yaegassy 🤘 that seems pretty promising, thank you for sharing. I’ll have to try that out myself.

from curlylint.

simonw avatar simonw commented on July 18, 2024

Whether or not this feature makes sense, this project is excellent - thank you so much! It just found a couple of bugs in Datasette. simonw/datasette@d0c752d

from curlylint.

thibaudcolas avatar thibaudcolas commented on July 18, 2024

Hey @simonw, well I’m glad you’re finding it helpful! 🙂 99% of the credit for those two issues should go to https://github.com/motet-a/jinjalint, from which most of Curlylint’s parser comes from (I’ve only changed the parser for a few bug fixes so far).


For auto-formatting – this is something I’m personally very interested in as well, as a heavy user of both Prettier and black. I’ve been keen to work on this for a while, but need to be realistic with the time commitment something like this would take, so the short answer is "not for now", I think.

The long answer is that there is some interest in making this happen in the Prettier world, and to me it feels like a good ecosystem for this to be done within, since there is so much similarity between all the curly template languages. So far the most promising attempt there is https://github.com/trivago/prettier-plugin-twig-melody, and I’m hoping this will be something we can leverage for Jinja / Django templates.

For Curlylint, I can see a few ways for this project to help make auto-formatting happen:

  • First there’s the parser. There aren’t so many parsers out there that provide a useful AST for both HTML, and template language syntax. This would obviously be a good basis for auto-formatting – assuming the parser is good you’d "just" need a printer for the AST. That parser needs work, regardless of whether it’s for linting or auto-formatting.
  • Then there’s the parser’s unit tests! Currently there aren’t many. I’d really like to write a lot, in a format that would be helpful to the current parser, but that could also be used to a JS-implemented parser.
  • And smoke tests. https://github.com/thibaudcolas/curlylint/tree/main/tests contains code from many projects partly for me to have an easy set of templates to test all kinds of static analysis on curly templates.

If you or anyone else wants to help with this, I can see a few options:

  • Testing Curlylint more. I’m only using it on a handful of projects currently, and have an ok understanding of the parser, but it really does need to be more battle-tested before I’d let any tool rewrite code based on it. Any feedback on that front is appreciated.
  • Same as the above, but with unit tests :) That parser code really needs its 100% coverage as a minimum.
  • Finally to depart from the above I’d also be interested for someone to investigate whether the existing indent rule could be re-purposed for automated indentation. It’s not something I’m too keen on myself (I’d rather work on a full-on parser!), but if it’s not that much work to make use of that existing indent logic, might as well.

from curlylint.

panosl avatar panosl commented on July 18, 2024

I'm also interested in the jinja2, django template formatter.

It seems that there is a package called "vsot", but unfortunately it is not maintained.

PRE-APLHA, mostly unmaintained

* https://pypi.org/project/vsot/

* https://github.com/benhowes/vsot

(Something, if it would be helpful.)

Of course, if there is a dedicated plugin for prettier, I'm sure that's fine.

Now that looks promising!

from curlylint.

thibaudcolas avatar thibaudcolas commented on July 18, 2024

Ah that’s really interesting, thank you for sharing it here. There aren’t that many parsers out there for HTML + template syntax, particularly with enough information for pretty-printing, so it’s always interesting to compare options at the very least.

from curlylint.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.