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

42 lines
945 B
Ruby
Raw Normal View History

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