Content blocks are commonly used models representing editable page partials.
Ruby
Switch branches/tags
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
lib
spec
.document
.gitignore
.rspec
Gemfile
Gemfile.lock
LICENSE.txt
README.rdoc
Rakefile
VERSION
content_blocks.gemspec

README.rdoc

Content Blocks

Content Blocks aims to be a tiny set of reusable AR models for site fragments. Currently it consists of only one model: Snippet. The following usage example will tell you more.

Installation

As a gem in your Gemfile:

gem 'content_blocks'

Usage

Given:

ContentBlocks::Snippet.create :label => :label_for_snippet, :content => 'h2. Title'
ContentBlocks::Snippet[:label_for_snippet].publish!

When:

<%= ContentBlocks::Snippet[:label_for_snippet].content %>

Then it will render textilized content column from Snippet model:

<h2>Title</h2>

I you'd rather like to access content without textilization, use:

<%= ContentBlocks::Snippet[:label_for_snippet].raw_content %>

You can have multiple snippets with the same label, only one can be published at the same time though. Snippets are also automatically created on first access if they don't exist.

Copyright

Copyright © 2010 Paweł Pacana. Released under MIT license.