1
0
Fork 0
mirror of https://github.com/sinatra/sinatra synced 2023-03-27 23:18:01 -04:00
sinatra/vendor/haml/lib/haml.rb
Blake Mizerany 85e1a4c944 docs
2007-10-04 15:40:12 -07:00

41 lines
945 B
Ruby

module Sinatra
module Haml # :nodoc:
module EventContext
# 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)
require 'haml'
body ::Haml::Engine.new(template).render(self)
end
# 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
def haml(template, options = {}, &layout)
render(template, :haml, options, &layout)
end
end
end
end