Comments (7)
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.
@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.
@yaegassy 🤘 that seems pretty promising, thank you for sharing. I’ll have to try that out myself.
from curlylint.
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.
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.
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.
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)
- When using the curlylint linter in Django templates it generates a false positive parse error HOT 1
- Ability to do simple checks on template tag content HOT 3
- `pip install curlylint` does not work due to incompatability with click 8.1.0 HOT 1
- Support Alpine.js syntax HOT 1
- Parsing fails for {% comment %} including number within HTML tag
- parse error expectation wrong HOT 1
- TypeError: can only concatenate str (not "Parser") to str HOT 1
- Parser fails on comment containing HTML tag
- Invalid test usage in Jinja2 isn't caught by linter
- Crash when closing HTML tags inside Jinja2 if statements HOT 2
- Action Required: Fix Renovate Configuration
- Tests from sdist fail HOT 3
- Stumbles over… I don't know what ;) HOT 3
- image_alt rule fails to find missing alt tag inside django block HOT 1
- invalid parse error HOT 1
- Make it possible to skip/ignore rules/linting on specific lines HOT 5
- Support for self closing tags (HTML / XML) HOT 4
- Handling <!doctype html> HOT 1
- Exclude folders/files from linting HOT 1
- Dependency Dashboard
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from curlylint.