Why?

DryViews provides extensions to ActionView::Helpers::CaptureHelper, which is part of ActionPack:

content_for_with_default

no_content_for

content_for (enhanced to play nice with the above methods)

The rails rendering chain is sort of inside out so the template rendering happens first, and this is what makes it possible to override everything! The template will ALWAYS override the layout, and a partial will always override a partial layout.

- no_content_for :key
# Use a dash (-) not equals (=)
# Will prevent a later content_for from rendering. This allows template overrides of layouts.
= content_for_with_default :key
# Use an equal (=) not a dash (-)
# You provide it with the default HAML via a block *or* a set of params that are the same as you would pass to a standard "render" call (i.e. :partial => 'foo', :locals => {:bar => 'bar'}).
= content_for :key
# Use an equal (=) not a dash (-)
# You provide it with a block, i.e. {render :partial => 'foo'}, and it will override content_for_with_default. It has the same precedence as no_content_for, so whichever is rendered first wins, so if a layout has either no_content_for or content_for (with or without default) the template can now override it.

Development

After checking out the repo, run bin/setup to install dependencies, and setup the test environment, including creating a role and a database. Then, run appraisal rake to run the tests. You can also run bin/console for an interactive prompt that will allow you to experiment.

To install this gem onto your local machine, run bundle exec rake install. To release a new version, update the version number in version.rb, and then run bundle exec rake release, which will create a git tag for the version, push git commits and tags, and push the .gem file to rubygems.org.

Running the tests

Setup has been implemented with bin/setup, so review the file to see what it will do before you:

bin/setup

Run the specs with rake:

appraisal rake

Or, run the specs without rake:

appraisal rspec

Contributing

Fork it

Create your feature branch (git checkout -b my-new-feature)

Commit your changes (git commit -am 'Added some feature')

Push to the branch (git push origin my-new-feature)

Create new Pull Request

Versioning

This library aims to adhere to Semantic Versioning 2.0.0.
Violations of this scheme should be reported as bugs. Specifically,
if a minor or patch version is released that breaks backward
compatibility, a new version should be immediately released that
restores compatibility. Breaking changes to the public API will
only be introduced with new major versions.

As a result of this policy, you can (and should) specify a
dependency on this gem using the Pessimistic Version Constraint with two digits of precision.