RailsCasts Pro episodes are now free!
Learn more or hide this
GitHub User: sandiegoscott
What if I want to use HAML in the presenter? I added lines to BasePresenter like so:
class BasePresenter include Haml::Helpers # access HAML def initialize(object, template) @object = object @template = template init_haml_helpers # init the helpers end def self.presents(name) define_method(name) do @object end end def h @template end #--------------------------------------------- def show_field( label, contents, options=nil ) haml_tag 'tr' do haml_tag 'td.label', label, options haml_tag 'td.field', contents ||= '' end end end
and used it like this in show.haml:
- presenter.show_field('Efficacy', presenter.efficacy)
and I can show that show_field is being called, but no HTML is produced. Maybe it is in the wrong context.
Shouldn't this line:
klass ||= "{object.class}Presenter".constantize
be
klass ||= "#{object.class}Presenter".constantize
?
What if I want to use HAML in the presenter? I added lines to BasePresenter like so:
and used it like this in show.haml:
- presenter.show_field('Efficacy', presenter.efficacy)
and I can show that show_field is being called, but no HTML is produced. Maybe it is in the wrong context.
Shouldn't this line:
klass ||= "{object.class}Presenter".constantize
be
klass ||= "#{object.class}Presenter".constantize
?