Created
December 18, 2012 19:07
-
-
Save edolopez/4330934 to your computer and use it in GitHub Desktop.
Script that converts 'haml' to 'erb'. It also accepts utf-8 encoding.
This file contains hidden or 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
| Encoding.default_external = 'UTF-8' | |
| Encoding.default_internal = 'UTF-8' | |
| require 'haml' | |
| class ErbEngine < Haml::Engine | |
| def push_script(text, preserve_script, in_tag = false, preserve_tag = false, | |
| escape_html = false, nuke_inner_whitespace = false) | |
| push_text "<%= #{text.strip} %>" | |
| end | |
| def push_silent(text, can_suppress = false) | |
| push_text "<% #{text.strip} %>" | |
| end | |
| end | |
| def haml_to_erb(haml) | |
| ErbEngine.new(haml, :attr_wrapper => '"').render | |
| end | |
| puts haml_to_erb(File.read('app/views/object/x.html.haml')) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment