Created
March 13, 2009 20:13
-
-
Save foca/78736 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "sinatra" | |
require "sinatra/rendering" | |
render_with :haml | |
get "/" do | |
render :homepage | |
end | |
get "/some-ajax-action", :provides => "application/javascript" do | |
partial :section | |
end | |
use_inline_templates! | |
__END__ | |
@@layout | |
%body | |
= yield | |
@@homepage | |
#section= partial :section | |
%a{ :href => "#" } Update via ajax | |
@@section | |
hi! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Sinatra | |
module Rendering | |
module Helpers | |
def render(view, options={}) | |
send self.class.rendering_engine || :erb, view, options | |
end | |
def partial(view, options={}) | |
render view, { :layout => false }.merge(options) | |
end | |
end | |
module Extensions | |
attr_reader :rendering_engine | |
def render_with(engine) | |
@rendering_engine=engine | |
end | |
end | |
end | |
helpers Rendering::Helpers | |
register Rendering::Extensions | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment