{"id":22740487,"url":"https://github.com/datarockets/rails-views","last_synced_at":"2025-04-14T05:52:33.427Z","repository":{"id":56890736,"uuid":"78120438","full_name":"datarockets/rails-views","owner":"datarockets","description":null,"archived":false,"fork":false,"pushed_at":"2018-11-09T15:34:20.000Z","size":20,"stargazers_count":7,"open_issues_count":10,"forks_count":0,"subscribers_count":23,"default_branch":"master","last_synced_at":"2025-04-11T23:18:54.157Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/datarockets.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-01-05T14:35:39.000Z","updated_at":"2020-09-22T18:48:40.000Z","dependencies_parsed_at":"2022-08-21T00:20:35.433Z","dependency_job_id":null,"html_url":"https://github.com/datarockets/rails-views","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/datarockets%2Frails-views","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/datarockets%2Frails-views/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/datarockets%2Frails-views/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/datarockets%2Frails-views/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/datarockets","download_url":"https://codeload.github.com/datarockets/rails-views/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248830389,"owners_count":21168272,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-12-10T23:09:06.285Z","updated_at":"2025-04-14T05:52:33.401Z","avatar_url":"https://github.com/datarockets.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Rails::Views\n\n*View Components for Ruby and Rails.*\n\nThe gem provides view models for Ruby web applications. View models are plain objects that represent a part of the web page. View models can also render views, and be nested.\n\nThis gem bases on [cells](https://github.com/trailblazer/cells).\n\n## Installation\n\nAdd this line to your application's Gemfile:\n\n```ruby\ngem 'rails-views'\n```\n\nAnd then execute:\n\n    $ bundle\n\n## Usage\n\nThis gem bases on [cells](https://github.com/trailblazer/cells), but includes only `Concept` logic.\n\nA view is a light-weight class with `show.slim` temlate with base view logic.\n\n```ruby\nclass Comment::Cell \u003c Rails::View\n\n  private\n\n  property :body, :author\n\n  def author_link\n    link_to \"#{author.email}\", author\n  end\nend\n```\n\n## Rendering\n\nGem provides logic for rendering cells instead of ActionView templates.\n\n```ruby\ndef CommentsController \u003c ApplicationController\n  def index\n    render cell: true # will render Comments::Cell\n  end\n\n  def show\n    @comment = Comment.find(params[:id])\n\n    render cell: :show, model: @comment # will render Comments::Show::Cell with @comment as model\n  end\n\n  def new\n    @comment = Comment.new\n    @user = User.find(params[:user_id])\n\n    render cell: 'user/comment', model: @comment, options: {user: @user} # will render User::Comment::Cell with @comment as model and user options\n  end\nend\n```\n\n## Helpers\n\nAlso gem provides new helpers for rails.\n\n### Flash\n\nProvide method for working with flash.\n\n```ruby\n= flash[:notice]\n```\n\n### Render partials array\n\nMethod `render_each_and_join` can render array of templates and join it in one string.\n\n```ruby\nclass User::Info::Cell \u003c Rails::View\n  private\n\n  def parts_of_info\n    %w(contact_information about jobs transactions_list)\n  end\n\n  def info_body\n    render_each_and_join(parts_of_info)\n  end\nend\n\nclass User::ShortInfo::Cell \u003c User::Info::Cell\n  private\n\n  def parts_of_info\n    %w(contact_information about)\n  end\nend\n```\n\n### Options\n\nProvide `options` reader. You can have automatic readers to the options's fields by using `::option`\n\n```ruby\nclass User::Comment::Cell \u003c Rails::View\n  private\n    options :user # delegate to options[:user]\n\n    delegate :email, to: :user, prefix: true\nend\n```\n\n## Contributing\n\n1. Fork it\n2. Create your feature branch (`git checkout -b my-new-feature`)\n3. Run the test suite and check the output (`rake`)\n4. Add tests for your feature or fix (please)\n5. Commit your changes (`git commit -am 'Add some feature'`)\n6. Push to the branch (`git push origin my-new-feature`)\n7. Create new Pull Request\n\nBug reports and pull requests are welcome on GitHub at https://github.com/datarockets/rails-views\n\n\n## License\n\nThe gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdatarockets%2Frails-views","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdatarockets%2Frails-views","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdatarockets%2Frails-views/lists"}