Skip to content

content_tag method expected behaviour is broken #640

@prikha

Description

@prikha

Help us help you! Please choose one:

  • [*] My app doesn't crash, but I'm getting unexpected behavior. So, I've described the unexpected behavior and suggested a new behavior.

Hi guys, and again I would like to ask if there are anyone using view helper react_component like so:

# slim template
= react_component 'PhoneBlock', {}, {} do
  ' Arbitrary content here
end

Apparently this one gives unexpected results:

Text Arbitrary content here would appear on the page twice. I haven't find a good solution yet, but the roots of the problem lay in the field of view context_buffer.

We do however use this hack:

def react_component(name, props = {}, options = {}, &block)
    ...
    if block_given?
      predefined_content = capture(&block)
      helper_obj.react_component(name, props, options) { predefined_content }
    else
      helper_obj.react_component(name, props, options)
    end
  end

That gives predictable results. We capture block output inside the view context and just pass it down.

Do you have any thoughts/directions on this?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions