Closed phoet closed 1 year ago
So do you mean linting or do you mean formatting? Assuming you mean formatting, yeah that doesn't exist at the moment. It would require a couple of steps. Here's a bit of a roadmap:
syntax_tree
and prettier_print
dependencies.SyntaxTree::Slim::parse(source)
to return the AST. This should use slim's own parser to parse the source. From a quick glance it looks like it uses a gem called Temple
under the hood, so I'd start with those docs.prettier_print
. You can see that done in every plugin.SyntaxTree::register_plugin
with your SyntaxTree::Slim
module, like we do in all the plugins. (Here's the JSON one.)Best of luck! I'll be happy to include it in the ruby-syntax-tree
GitHub org once you get started, or you could keep it on your own.
in case anyone is interested, i started to play around with it here https://github.com/phoet/syntax_tree-slim/blob/main/test/syntax_tree/slim_test.rb#L27-L61
I saw that the plugin can lint
.haml
files using thesyntax_tree-haml
gem. I assume there is no alternative for slim templates? I've recently had a look if there is anything providing auto-formating for slim, but only foundslim-lint
which unfortunately does not offer such a functionality.What would need to be done to add slim? Pointers appreciated.