threedaymonk / htmlbeautifier

A normaliser/beautifier for HTML that also understands embedded Ruby. Ideal for tidying up Rails templates.
MIT License
333 stars 58 forks source link

Version 1.2.0 Add support for Liquid syntax #35

Closed forsbergplustwo closed 8 years ago

forsbergplustwo commented 8 years ago

This pull request adds support for the Liquid (https://github.com/Shopify/liquid) syntax. It is very close to erb with only a slightly different opening/closing tag regex and indent/outdent keywords.

I got errors running tests on the master branch of the original project so instead I've tested on numerous ruby/liquid/html files, as well as the code in the document_spec.rb file and results pass :+1:

I cleaned up 3 of 4 Rubocop violations, but the last one is not possible without larger refactoring: Class has too many lines. It went from 99 to 107 lines.

I know this may not be something you want to add in the core project, but I thought I'd send upstream just in case ;)

threedaymonk commented 8 years ago

I think this is very nice to have, but I probably want to do it as part of a much larger refactor I have in mind.

forsbergplustwo commented 8 years ago

No problems at all, makes sense. The Liquid code would need a slight improvement now anyway, as they have recently added a new syntax for controlling whitespace as well. So contorl tags in Liquid can now looks like any of these:

{% if x == y %} {%- if x == y %} {% if x == y -%} {%- if x == y -%}

Anyway, thanks again for the great gem 👍