Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Prepare ERB for SLIM
# Not great, but better than doing everything by hand...
def prepare_erb_for_slim(body)
# remove all %>
body.gsub!(/%> */, '')
# convert <%-/= to -
body.gsub!(/<%(-|=) */, '\1 ')
# convert <% to -
body.gsub!(/<% */, '- ')
# remove ends
body.gsub!(/- end/, '')
# remove all closing brackets
body.gsub!(/ *<\/\w+> */, '')
# remove HTML opening tag bracket
body.gsub!(/<(.+?)> */, '\1 ')
return body
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment