Nerb

A pocket-sized CMS in the form of a Merb slice.


  1. Rake tasks to package/install the gem - edit this to modify the manifest.
  2. The slice application: controllers, models, helpers, views.
  3. The default layout, as specified in Merb::Slices::config[:nerb][:layout] change this to :application to use the app’s layout.
  4. Standard rake tasks available to your application.
  5. Your custom application rake tasks.
  6. The main slice file - contains all slice setup logic/config.
  7. Public assets you (optionally) install using rake slices:nerb:install
  8. Specs for basis slice behaviour - you usually adapt these for your slice.
  9. Stubs of classes/views/files for the end-user to override - usually these mimic the files in app/ and/or public/; use rake slices:nerb:stubs to get started with the override stubs. Also, slices:nerb:patch will copy over views to override in addition to the files found in /stubs.

To see all available tasks for Nerb run:

rake -T slices:nerb


Instructions for installation:

file: config/init.rb

add the slice as a regular dependency

dependency ‘nerb’

if needed, configure which slices to load and in which order

Merb::Plugins.config[:merb_slices] = { :queue => [“Nerb”, …] }

optionally configure the plugins in a before_app_loads callback

Merb::BootLoader.before_app_loads do

Merb::Slices::config[:nerb][:option] = value

end

file: config/router.rb

example: /nerb/:controller/:action/:id

r.add_slice(:Nerb)

example: /foo/:controller/:action/:id

r.add_slice(:Nerb, ‘foo’) # same as :path => ‘foo’

example: /:lang/:controller/:action/:id (with :a param set)

r.add_slice(:Nerb, :path => ‘:lang’, :params => { :a => ‘b’ })

example: /:controller/:action/:id

r.slice(:Nerb)

Normally you should also run the following rake task:

rake slices:nerb:install


You can put your application-level overrides in:

host-app/slices/nerb/app - controllers, models, views …

Templates are located in this order:

  1. host-app/slices/nerb/app/views/*
  2. gems/nerb/app/views/*
  3. host-app/app/views/*

You can use the host application’s layout by configuring the nerb slice in a before_app_loads block:

Merb::Slices.config[:nerb] = { :layout => :application }

By default :nerb is used. If you need to override stylesheets or javascripts, just specify your own files in your layout instead/in addition to the ones supplied (if any) in host-app/public/slices/nerb.

In any case don’t edit those files directly as they may be clobbered any time rake nerb:install is run.