Class: Freddie::Handlers::Template

Inherits:
Base
  • Object
show all
Includes:
Endpoint
Defined in:
lib/freddie/handlers.rb

Instance Attribute Summary

Attributes inherited from Base

#args, #block, #env

Instance Method Summary collapse

Methods included from Endpoint

#after_perform, #before_perform

Methods inherited from Base

#after_perform, #before_perform, #call, call, #context, #finish!, #finished?, #initialize, #layout, #method_missing, #params, #perform_freddie_block, #request, #response, #session

Constructor Details

This class inherits a constructor from Freddie::Handlers::Base

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Freddie::Handlers::Base

Instance Method Details

#performObject



131
132
133
134
135
136
137
138
139
140
# File 'lib/freddie/handlers.rb', line 131

def perform
  name = args.shift
  variables = args.shift || {}

  html = Tilt.new("views/%s" % name).render(context, variables)
  if env['freddie.layout'].present?
    html = Tilt.new("views/#{env['freddie.layout']}").render(context) { html }
  end
  response.body << html
end