Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Multipe calls to render should concat the calls #72

Closed
bradphelan opened this Issue Mar 14, 2012 · 3 comments

Comments

Projects
None yet
2 participants
  replace "#view1", :view => :view1 if invitation
  replace "#view2", :view => :view2 if invitation
  replace "#view3", :view => :view3 if invitation

would be really convienient

I get it :)

      txt = ""
      txt << ( replace "##{widget_id}", :view => :display  )
      txt << ( replace "section#invite", :text => "" )

Bloody awsome!

@bradphelan bradphelan closed this Mar 14, 2012

@bradphelan bradphelan reopened this Mar 14, 2012

Added this to my base widget

  class WidgetRenderBuffer
    def initialize w
      @widget = w
      @buffer = ""
    end

    def replace *args
      @buffer << @widget.replace(*args)
    end

    def render *args
      @buffer << @widget.render(@args)
    end

    def to_s
      @buffer
    end
  end

  def render_buffer
    buffer = WidgetRenderBuffer.new self
    yield buffer
    buffer.to_s
  end

so I can use it this way

  render_buffer do |b|
    b.replace "##{widget_id}", :view => :display if invitation
    b.replace "section#invite", :text => ""
  end

A bit nicer than noisy string concat stuff.

Owner

apotonick commented Mar 15, 2012

You could also do

render ...., :if => invitation +
render .... +
replace ....

where render and replace needed to return a blank string when :if was false.

@apotonick apotonick closed this Nov 24, 2012

kuraga referenced this issue in kuraga/apotomo Jul 24, 2013

@kuraga kuraga referenced this issue Jul 24, 2013

Closed

Render buffer #100

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