{"id":13503618,"url":"https://github.com/clearwater-rb/clearwater","last_synced_at":"2025-04-12T22:17:19.861Z","repository":{"id":24302272,"uuid":"27697718","full_name":"clearwater-rb/clearwater","owner":"clearwater-rb","description":"Component-based Ruby front-end framework","archived":false,"fork":false,"pushed_at":"2024-10-30T11:47:26.000Z","size":506,"stargazers_count":596,"open_issues_count":12,"forks_count":20,"subscribers_count":34,"default_branch":"master","last_synced_at":"2025-04-12T22:17:14.568Z","etag":null,"topics":["clearwater","front-end","ruby"],"latest_commit_sha":null,"homepage":"http://clearwaterrb.org","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/clearwater-rb.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2014-12-08T04:32:23.000Z","updated_at":"2024-11-28T16:30:23.000Z","dependencies_parsed_at":"2022-09-01T13:01:03.833Z","dependency_job_id":"fca66bc5-d6a7-4a94-960f-68c83384f2a8","html_url":"https://github.com/clearwater-rb/clearwater","commit_stats":null,"previous_names":[],"tags_count":26,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/clearwater-rb%2Fclearwater","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/clearwater-rb%2Fclearwater/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/clearwater-rb%2Fclearwater/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/clearwater-rb%2Fclearwater/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/clearwater-rb","download_url":"https://codeload.github.com/clearwater-rb/clearwater/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248637786,"owners_count":21137538,"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":["clearwater","front-end","ruby"],"created_at":"2024-07-31T23:00:41.633Z","updated_at":"2025-04-12T22:17:19.820Z","avatar_url":"https://github.com/clearwater-rb.png","language":"Ruby","funding_links":[],"categories":["Uncategorized","Ruby"],"sub_categories":["Uncategorized"],"readme":"clearwater\n----------\n\n [![Join Chat](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/clearwater-rb/clearwater) [![Quality](http://img.shields.io/codeclimate/github/clearwater-rb/clearwater.svg?style=flat-square)](https://codeclimate.com/github/clearwater-rb/clearwater) [![Build](http://img.shields.io/travis-ci/clearwater-rb/clearwater.svg?style=flat-square)](https://travis-ci.org/clearwater-rb/clearwater) [![Downloads](http://img.shields.io/gem/dtv/clearwater.svg?style=flat-square)](https://rubygems.org/gems/clearwater) [![Issues](http://img.shields.io/github/issues/clearwater-rb/clearwater.svg?style=flat-square)](http://github.com/clearwater-rb/clearwater/issues) [![License](http://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square)](http://opensource.org/licenses/MIT) [![Version](http://img.shields.io/gem/v/clearwater.svg?style=flat-square)](https://rubygems.org/gems/clearwater)\n\nClearwater is a rich front-end framework for building fast, reasonable, and easily composable browser applications in Ruby. It renders to a virtual DOM and applies the virtual DOM to the browser's actual DOM to update only what has changed on the page.\n\nInstalling\n==========\n\nAdd these lines to your application's Gemfile:\n\n``` ruby\ngem 'clearwater'\ngem 'opal-rails' # Only if you're using Rails\n```\n\nUsing\n=====\n\nThis is a minimum-viable Clearwater app:\n\n```ruby\nrequire 'opal'\nrequire 'clearwater'\n\nclass HelloWorld\n  include Clearwater::Component\n  \n  def render\n    h1('Hello, world!')\n  end\nend\n\napp = Clearwater::Application.new(component: HelloWorld.new)\napp.call\n```\n\nClearwater has three distinct parts:\n\n1. The component: the presenter and template engine\n1. The router (optional): the dispatcher and control\n1. The application: the \"Go\" button\n\n**The Component**\n``` ruby\nclass Blog\n  # All components need a set of behavior, but don't worry it's not a massive list.\n  include Clearwater::Component\n\n  # This method needs to return a virtual-DOM element using the element DSL.\n  # The DSL is provided by the Clearwater::Component mixin.\n  def render\n    div([\n      Articles.new,\n      Biography.new,\n    ])\n  end\nend\n```\n\nWhile we use two components in this example, you can use all of these as well:\n\n``` ruby\n# \u003cdiv id=\"foo\"\u003e\n#   \u003ch1\u003eHeading\u003c/h1\u003e\n#   \u003carticle\u003ehello!\u003c/article\u003e\n# \u003c/div\u003e\ndef render\n  div({ id: 'foo' }, [\n    h1('Heading'),\n    article('hello!'),\n  ])\nend\n\n# \u003cdiv\u003eHello, world!\u003c/div\u003e\ndef render\n  div('Hello, world!')\nend\n\n# \u003cdiv\u003e123\u003c/div\u003e\ndef render\n  div(123)\nend\n\n# \u003cdiv\u003e\u003c/div\u003e\ndef render\n  div\nend\n```\n\n**The Router**\n\n``` ruby\nrouter = Clearwater::Router.new do\n  # A route with a block contains subordinate routes\n  route 'blog' =\u003e Blog.new do # /blog\n    route 'new_article' =\u003e NewArticle.new # /blog/new_article\n\n    # This path contains a dynamic segment. Inside this component, you can use\n    # router.params[:article_id] to return the value for this segment of the\n    # URL. So for \"/articles/123\", router.params[:article_id] would be \"123\".\n    route ':article_id' =\u003e ArticleReader.new # /blog/123\n  end\nend\n```\n\n## Using with Rails\n\nYou can also use Clearwater as part of the Rails asset pipeline. First create your Clearwater application (replace `app/assets/javascripts/application.js` with this file):\n\n### `app/assets/javascripts/application.rb`\n```ruby\nrequire 'opal' # Not necessary if you load Opal from a CDN\nrequire 'clearwater'\n\nclass Layout\n  include Clearwater::Component\n\n  def render\n    h1('Hello, world!')\n  end\nend\n\napp = Clearwater::Application.new(component: Layout.new)\napp.call\n```\n\n### `app/views/layouts/application.html.erb`\n\n```erb\n\u003c!DOCTYPE html\u003e\n\u003chtml\u003e\n  \u003c!-- snip --\u003e\n\n  \u003cbody\u003e\n    \u003c!--\n      We load the JS in the body tag to ensure the element exists so we can\n      render to it. Otherwise, we need to use events on the document before we\n      instantiate and call the Clearwater app. And that's no fun.\n    --\u003e\n    \u003c%= javascript_include_tag 'application' %\u003e\n  \u003c/body\u003e\n\u003c/html\u003e\n```\n\nThen you need to get Rails to render a blank page, so add these two routes:\n\n### `config/routes.rb`\n```ruby\nroot 'home#index'\nget '*all' =\u003e 'home#index'\n```\n\nYou can omit the second line if your Clearwater app doesn't use routing. It just tells Rails to let your Clearwater app handle all routes.\n\n### `app/controllers/home_controller.rb`\n```ruby\nclass HomeController \u003c ApplicationController\n  def index\n  end\nend\n```\n\n### `app/views/home/index.html.erb`\n```html\n\u003c!-- This page intentionally left blank --\u003e\n```\n\nYou can use the Rails generators to generate the controller and view (`rails g controller home index`), but it won't set up the root and catch-all routes, so you'll still need to do that manually.\n\nOnce you've added those files, refresh the page. You should see \"Hello, world!\" in big, bold letters. Congrats! You've built your first Clearwater app on Rails!\n\n## Using with Roda\n\nIf you're using Roda, you'll want to use the [`roda-opal_assets` gem](https://github.com/clearwater-rb/roda-opal_assets) to get an asset-pipeline-style workflow for compiling your Clearwater app into JavaScript.\n\n## Getting Started\n\nUse the [`clearwater-roda`](https://github.com/clearwater-rb/clearwater-roda) gem to generate a starter Clearwater app that demonstrates many components working together, routing, and even state management (via [`grand_central`](https://github.com/clearwater-rb/grand_central)).\n\n## Experiment!\n\nYou can experiment with Clearwater using the [Clearwater Playground](https://clearwater-rb-playground.herokuapp.com). You can also explore [other saved playground experiments](https://clearwater-rb-playground.herokuapp.com/playgrounds).\n\nContributing\n============\nThis project is governed by a [Code of Conduct](CODE_OF_CONDUCT.md)\n\n  1. Fork it\n  1. Branch it\n  1. Hack it\n  1. Save it\n  1. Commit it\n  1. Push it\n  5. Pull-request it\n\n\nLicense\n=======\n\nCopyright (c) 2014-2018  Jamie Gaskins\n\nMIT License\n\nPermission is hereby granted, free of charge, to any person obtaining\na copy of this software and associated documentation files (the\n\"Software\"), to deal in the Software without restriction, including\nwithout limitation the rights to use, copy, modify, merge, publish,\ndistribute, sublicense, and/or sell copies of the Software, and to\npermit persons to whom the Software is furnished to do so, subject to\nthe following conditions:\n\nThe above copyright notice and this permission notice shall be\nincluded in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND,\nEXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\nNONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE\nLIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION\nOF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION\nWITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fclearwater-rb%2Fclearwater","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fclearwater-rb%2Fclearwater","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fclearwater-rb%2Fclearwater/lists"}