Class: Sablon::Template

Inherits:
Object
  • Object
show all
Defined in:
lib/sablon/template.rb

Instance Method Summary collapse

Constructor Details

#initialize(path) ⇒ Template



3
4
5
# File 'lib/sablon/template.rb', line 3

def initialize(path)
  @path = path
end

Instance Method Details

#render_to_file(output_path, context, properties = {}) ⇒ Object

Same as render_to_string but writes the processed template to output_path.



8
9
10
11
12
# File 'lib/sablon/template.rb', line 8

def render_to_file(output_path, context, properties = {})
  File.open(output_path, 'wb') do |f|
    f.write render_to_string(context, properties)
  end
end

#render_to_string(context, properties = {}) ⇒ Object

Process the template. The context hash will be available in the template.



15
16
17
# File 'lib/sablon/template.rb', line 15

def render_to_string(context, properties = {})
  render(context, properties).string
end