Syntax Tree support for ERB.
This is not ready for production use just yet, still need to work on:
- Comments
- Blocks using
do
- Blank lines
- Probably more
Currently handles
- ERB tags with and without output
- ERB tags inside strings
- HTML tags with attributes
- HTML tags with and without closing tags
- ERB
if
,elsif
andelse
statements - Text output
- Formatting the ruby code inside the ERB tags (using syntax_tree itself)
Add this line to your application's Gemfile:
gem github: "davidwessman/syntax_tree-erb"
From code:
require "syntax_tree/erb"
pp SyntaxTree::ERB.parse(source) # print out the AST
puts SyntaxTree::ERB.format(source) # format the AST
Bug reports and pull requests are welcome on GitHub at https://github.com/davidwessman/syntax_tree-erb.
The gem is available as open source under the terms of the MIT License.