Last active
August 29, 2015 13:56
-
-
Save dannguyen/8790961 to your computer and use it in GitHub Desktop.
Prepare ERB for SLIM
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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