Skip to content

Instantly share code, notes, and snippets.

@parndt
Created January 17, 2012 22:44
Show Gist options
  • Save parndt/1629498 to your computer and use it in GitHub Desktop.
Save parndt/1629498 to your computer and use it in GitHub Desktop.
A DSL for defining different page types for Refinery CMS. Allows setting default page parts per type and defining which template shall render when the page is requested.
Refinery::Pages.configure do |pages|
pages.types do |types|
types.define :home do |home|
home.parts = %w[intro body]
home.template = 'refinery/pages/home' # this is automatic but shows overriding
end
types.define :show do |show|
show.parts = %w[body side]
# show.template is automatically 'refinery/pages/show' and thus not required.
end
types.define :custom do |custom|
# can specify a completely different template, but conventions are nicer.
custom.template = 'random/other/template' # this would render app/views/random/other/template.html.{erb|haml}
custom.parts = %w[header footer body bucket]
end
# the result of not passing a block is:
# types.template = 'refinery/pages/defaults'
# types.parts = Refinery::Pages.default_parts
types.define :defaults
end
end
@parndt
Copy link
Author

parndt commented Jan 17, 2012

The view would look something like:

Preview

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment