Skip to content
New issue

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

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stream Tag Builder: Support :renderable arguments #569

Merged

Commits on Sep 16, 2024

  1. Stream Tag Builder: Support :renderable arguments

    When passed a valid `:renderable` option (like an object that responds
    to `#render_in`), treat that object as both the `<turbo-stream>`
    element's template contents _and_ attempt to treat it as the target.
    
    For example, consider a simplified "component" class:
    
    ```ruby
    class Component
      extend ActiveModel::Naming
    
      def initialize(id:, content:) = (@id, @content = id, content)
      def render_in(...) = @content
      def to_key = [@id]
    end
    
    component = Component.new(id: 1, content: "Hello, world")
    
    turbo_stream.update(component) # => <turbo-stream action="update" target="component_1"><template>Hello, world</template></turbo-stream>
    ```
    seanpdoyle committed Sep 16, 2024
    Configuration menu
    Copy the full SHA
    5038ed8 View commit details
    Browse the repository at this point in the history