Skip to content

Instantly share code, notes, and snippets.

@lucasluitjes
Last active November 25, 2017 11:10
Show Gist options
  • Save lucasluitjes/7c2f7edb7e511c602b3762c5b232e7d2 to your computer and use it in GitHub Desktop.
Save lucasluitjes/7c2f7edb7e511c602b3762c5b232e7d2 to your computer and use it in GitHub Desktop.
irb> require 'parser/current'
irb> require 'rexml/document'
irb> snippet = 'f.text_field :attr, placeholder: "placeholder text"'
irb> exp = Parser::CurrentRuby.parse(snippet)
irb> xml = XMLAST.new(exp)
irb> xml.doc.write(STDOUT, 2)
<root>
<send>
<send>
<nilclass-val />
<symbol-val />
</send>
<symbol-val />
<sym>
<symbol-val />
</sym>
<hash>
<pair>
<sym>
<symbol-val />
</sym>
<str>
<string-val />
</str>
</pair>
</hash>
</send>
</root>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment