Module: HamlMonkeyPatch
- Included in:
- Haml::Filters::Code
- Defined in:
- lib/middleman-syntax/haml_monkey_patch.rb
Instance Method Summary collapse
Instance Method Details
#render(code) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/middleman-syntax/haml_monkey_patch.rb', line 5 def render(code) code = code.rstrip code = code.encode(Encoding::UTF_8) # Allow language to be specified via a special comment like: # # lang: ruby if code.lines.first =~ /\A\s*#\s*lang:\s*(\w+)$/ language = $1 code = code.lines.to_a[1..-1].join # Strip first line end Middleman::Syntax::Highlighter.highlight(code, language) end |