2007-09-25 01:07:31 +00:00
|
|
|
module Sinatra
|
|
|
|
|
2007-10-04 15:40:12 -07:00
|
|
|
module Haml # :nodoc:
|
2007-09-25 01:07:31 +00:00
|
|
|
|
2007-10-01 01:10:46 -07:00
|
|
|
module EventContext
|
2007-09-25 01:07:31 +00:00
|
|
|
|
2007-10-04 15:40:12 -07:00
|
|
|
# Renders raw haml in within the events context.
|
|
|
|
#
|
|
|
|
# This can be use to if you already have the template on hand and don't
|
|
|
|
# need a layout. This is speedier than using haml
|
|
|
|
#
|
|
|
|
def render_haml(template)
|
2007-10-01 01:10:46 -07:00
|
|
|
require 'haml'
|
2007-10-04 15:40:12 -07:00
|
|
|
body ::Haml::Engine.new(template).render(self)
|
2007-09-25 01:07:31 +00:00
|
|
|
end
|
|
|
|
|
2007-10-04 15:40:12 -07:00
|
|
|
# Renders Haml within an event.
|
|
|
|
#
|
|
|
|
# Inline example:
|
|
|
|
#
|
|
|
|
# get '/foo' do
|
|
|
|
# haml '== The time is #{Time.now}'
|
|
|
|
# end
|
|
|
|
#
|
|
|
|
# Template example:
|
|
|
|
#
|
|
|
|
# get '/foo' do
|
|
|
|
# haml :foo #=> reads and renders view/foo.haml
|
|
|
|
# end
|
|
|
|
#
|
|
|
|
# For options, see Sinatra::Renderer
|
|
|
|
#
|
|
|
|
# See also: Sinatra::Renderer
|
2007-10-01 01:10:46 -07:00
|
|
|
def haml(template, options = {}, &layout)
|
|
|
|
render(template, :haml, options, &layout)
|
|
|
|
end
|
2007-09-25 01:07:31 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|