Class: Pancake::Mixins::Render::Template

Inherits:
Object
  • Object
show all
Defined in:
lib/pancake/mixins/render/template.rb

Defined Under Namespace

Classes: NotFound, UnamedTemplate

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, owner, path) ⇒ Template

Returns a new instance of Template.

Raises:



10
11
12
13
14
15
# File 'lib/pancake/mixins/render/template.rb', line 10

def initialize(name, owner, path)
  @name, @owner, @path = name, owner, path
  raise UnamedTemplate unless name
  raise NotFound unless File.exists?(path)
  @renderer = Tilt.new(path)
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



8
9
10
# File 'lib/pancake/mixins/render/template.rb', line 8

def name
  @name
end

#ownerObject (readonly)

Returns the value of attribute owner.



8
9
10
# File 'lib/pancake/mixins/render/template.rb', line 8

def owner
  @owner
end

#pathObject (readonly)

Returns the value of attribute path.



8
9
10
# File 'lib/pancake/mixins/render/template.rb', line 8

def path
  @path
end

#rendererObject (readonly)

Returns the value of attribute renderer.



8
9
10
# File 'lib/pancake/mixins/render/template.rb', line 8

def renderer
  @renderer
end

Instance Method Details

#render(context = ViewContext.new, opts = {}) ⇒ Object



17
18
19
# File 'lib/pancake/mixins/render/template.rb', line 17

def render(context = ViewContext.new, opts = {})
  @renderer.render(context, opts)
end