Effigy

brilliant plan needs work

I was browsing through my lost tweets and found this tweet by Mojombo, promoting this wonderful idea called Effigy.

I am wonderfully amazed by the simplicity of the concept and wonder why I it hasn't been done before (although Wicket does something similar). It gives true power to the View as seen as part of an MVC framework. The view tends to clutter with Control stuffs, but Effigy might have a good chance of stopping that.

I had to try it immediatly; and hooray! It works!

(what the docs of Effigy don't mention is that you need to add

  config.gem "effigy"


to you config/environment.rb, but that was quickly figures out)

 

I wondered how Effigy would work with the Rails Helpers, so I tried the following:

class FooIndexView < Effigy::Rails::View 
  def transform 
    text('h1', @title) 
    attr( 
        'a#menu', 
        :href => ActionView::Helpers::UrlHelper.url_for( { :controller => 'foo', :action => 'index' } ) 
    ) 
  end
end

Doesn't work-station. Effigy interferes and somehow ActionView::Helpers::UrlHelper does not contain 'url_for' according to ruby. But when I second guess that on script/console like this:

>> ActionView::Helpers::UrlHelper.instance_methods.include? "url_for"
=> true

And when I peek in the url_helper.rb it quite clearly states that there is a def url_for(options = {}).

Why this isn't working is beyond me, but I will be looking in to it. When I find something, I'll leave a comment (and if you have the solution, please let me know).

So there is some work to do for jferis and his Effigy; because the loss of the ActionView::Helpers is somewhat unbearable (for me @ least)

Apart from that, getting stuff like observe_field() and such in seems a challenge. Perhaps Effigy should allow the use of ERb as a template (Checked it, doesn't work). This would allow the helpers to work and to have a specialized view mechanism for stuffs that tend to end-up in the controller, because there is also logic that needs be in the view.

I forked Effigy on github and when I find the time I will try to get this plan together




Comments


Want to comment?



π