Skip to content

Instantly share code, notes, and snippets.

@anthonycrumley
Created May 7, 2009 18:09
Show Gist options
  • Save anthonycrumley/108240 to your computer and use it in GitHub Desktop.
Save anthonycrumley/108240 to your computer and use it in GitHub Desktop.
Rails view DSL notes

Rails needs to support the creation of view DSLs. This could be called by the plugin on initialization or by the app in the environment.rb.

ActionView::Dsl.load Gridzilla::Base ActionView::Dsl.unload Gridzilla::Base

Instance level sub-DSLs that would be used in the higher level DSL.

self.load_dsl Gridzilla::Rows self.load_dsl Gridzill::Rows

Options:

:namespace => “blah” :rename => {:method => :new_method}

or

ActionView::Dsl.load Gridzilla::Base do namespace “blah” rename :method, :new_method end

There needs to be a clean way of dealing with state within the DSL. This may or may not be an issue depending on the implementation of the DSL. If it is mixed into the view then it is important to keep DSLs from stepping on view instance variables and such.

There are top level methods that should be included into ActionView::Base. In the context of Gridzilla that would be the Gridzilla::Base#grid. If a plugin is all top level methods then it is just a helper and not a DSL.

helper_methods → DSL Language → DSL Sub Language

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