Luitjes IT | erb2builder
14-Apr-2022 1155
As we were building a new kind of ruby-based no-code platform, we ran into a problem. There is great tooling for parsing Ruby code, and there is great tooling for parsing HTML code. But when you deal with HTML ERB templates, you end up mostly ignoring either the Ruby or the HTML.This is why editors, linters, and tools like Rubocop generally don’t do quite as well on HTML ERB templates.We ended up combining Nokogumbo, Treetop, and the parser gem, to build a custom HTML ERB parser. This parser generates an abstract syntax tree that retains both the HTML structure and the Ruby structure.Pretty cool, but of course there is zero tooling for our weird custom abstract syntax tree format.
Luitjes IT | erb2builder #ruby #rubydeveloper #rubyonrails #Luitjes #erb2builder https://rubyonrails.ba/link/luitjes-it-erb2builder