Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
akzhan committed Jan 13, 2011
1 parent 7d6c096 commit 74a2a02
Show file tree
Hide file tree
Showing 6 changed files with 2 additions and 365 deletions.
22 changes: 0 additions & 22 deletions LICENSE

This file was deleted.

54 changes: 2 additions & 52 deletions README.rdoc
@@ -1,53 +1,3 @@
= ContentFor2
= Attention

Small extension for the Sinatra[http://sinatrarb.com] web framework
that allows you to use the following helpers in your views:

<% content_for :some_key do %>
<chunk of="html">...</chunk>
<% end %>

<% yield_content :some_key %>

This allows you to capture blocks inside views to be rendered later
in this request. For example, to populate different parts of your
layout from your view.

When using this with the Haml rendering engine, you should do the
following:

- content_for :some_key do
%chunk{ :of => "html" } ...

= yield_content :some_key

<b>Note</b> that with ERB <tt>yield_content</tt> is called <b>without</b>
an '=' block (<tt><%= %></tt>), but with Haml it uses <tt>= yield_content</tt>.

Using an '=' block in ERB will output the content twice for each block,
so if you have problems with that, make sure to check for this.

<B>Note</b> Use <tt><%= yield_content ... %></tt> in Erubis.

== Usage

If you're writing "classic" style apps, then requring
<tt>sinatra/content_for2</tt> should be enough. If you're writing
"classy" apps, then you also need to call
<tt>helpers Sinatra::ContentFor2</tt> in your app definition.

== And how is this useful?

For example, some of your views might need a few javascript tags and
stylesheets, but you don't want to force this files in all your pages.
Then you can put <tt><% yield_content :scripts_and_styles %></tt> on
your layout, inside the <head> tag, and each view can call
<tt>content_for</tt> setting the appropriate set of tags that should
be added to the layout.

== Credits

Code by foca[http://github.com/foca], inspired on the Ruby on Rails
helpers with the same name. Haml support by mattly[http://github.com/mattly].
Erubis support by hiroyuki[http://github.com/hryk].
Bundler/etc. unicode compatibility by arnabc[https://github.com/arnabc] and akzhan[https://github.com/akzhan].
Home has been moved to Undev[https://github.com/Undev/sinatra-content-for2] organization
33 changes: 0 additions & 33 deletions Rakefile

This file was deleted.

65 changes: 0 additions & 65 deletions lib/sinatra/content_for2.rb

This file was deleted.

37 changes: 0 additions & 37 deletions sinatra-content-for2.gemspec

This file was deleted.

156 changes: 0 additions & 156 deletions test/content_for_test.rb

This file was deleted.

0 comments on commit 74a2a02

Please sign in to comment.