Skip to content

Instantly share code, notes, and snippets.

@radar
Forked from parndt/gist:1629498
Created January 18, 2012 04:41
Show Gist options
  • Save radar/1631012 to your computer and use it in GitHub Desktop.
Save radar/1631012 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
types do
define :home do
self.parts = %w[intro body]
self.template = 'refinery/pages/home' # this is automatic but shows overriding
end
define :show do
self.parts = %w[body side]
# self.template is automatically 'refinery/pages/show' and thus not required.
end
define :custom do
# can specify a completely different template, but conventions are nicer.
self.template = 'random/other/template' # this would render app/views/random/other/template.html.{erb|haml}
self.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
define :defaults
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment