Module: Intranet::Core::HamlWrapper

Defined in:
lib/intranet/core/haml_wrapper.rb

Overview

Wrapps the Haml engine from the Haml gem. This module has to be included in any class wanting to generate a HTML/XML from HAML templates.

Instance Method Summary collapse

Instance Method Details

#to_markup(template, content = {}) ⇒ String

Generate the HTML/XML from a given HAML template.

Parameters:

  • template (String)

    The name of the HAML template to use.

  • content (Hash) (defaults to: {})

    The additional content required to generate the HTML/XML.

Returns:

  • (String)

    The HTML/XML content.



40
41
42
43
44
45
# File 'lib/intranet/core/haml_wrapper.rb', line 40

def to_markup(template, content = {})
  fd = File.read(find_template(template))
  Haml::Engine.new(fd, escape_html: false).render(self, content)
rescue Errno::ENOENT # template file does not exists
  ''
end