Skip to content
This repository was archived by the owner on Oct 19, 2018. It is now read-only.
This repository was archived by the owner on Oct 19, 2018. It is now read-only.

better syntax for specifying render method #149

Closed
@catmando

Description

@catmando

allow the render method to be specified like this:

  class Foo < React::Component::Base 
    render do 
      div.foo do 
        "hello".span
        "there".span 
      end
    end
  end

as an alternative to

  class Foo < React::Component::Base 
    def render
      div.foo do 
        "hello".span
        "there".span 
      end
    end
  end

Why?

  1. render methods are very often longer than the 10 lines recommend by style guides. Specifying the render method as a block avoids linter (i.e. rubocop) errors.
  2. we can now also specify the container as the first parameter, shortening things up:
class Foo < React::Component::Base 
  render(:div, class: :foo) do 
    "hello".span
    "there".span 
  end
end

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