{"id":18426401,"url":"https://github.com/complate/complate-ruby","last_synced_at":"2025-07-24T10:06:54.346Z","repository":{"id":94858491,"uuid":"92650224","full_name":"complate/complate-ruby","owner":"complate","description":"Use complate with Ruby and Rails","archived":false,"fork":false,"pushed_at":"2020-07-16T15:54:03.000Z","size":134,"stargazers_count":1,"open_issues_count":5,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-13T20:02:56.164Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/complate.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"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":"2017-05-28T08:53:23.000Z","updated_at":"2020-03-16T16:27:41.000Z","dependencies_parsed_at":"2023-07-29T13:15:12.380Z","dependency_job_id":null,"html_url":"https://github.com/complate/complate-ruby","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/complate/complate-ruby","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/complate%2Fcomplate-ruby","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/complate%2Fcomplate-ruby/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/complate%2Fcomplate-ruby/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/complate%2Fcomplate-ruby/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/complate","download_url":"https://codeload.github.com/complate/complate-ruby/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/complate%2Fcomplate-ruby/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266823662,"owners_count":23990051,"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","status":"online","status_checked_at":"2025-07-24T02:00:09.469Z","response_time":99,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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-11-06T05:07:51.014Z","updated_at":"2025-07-24T10:06:54.321Z","avatar_url":"https://github.com/complate.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# complate for Ruby\n\nThis is a Ruby on Rails and pure Ruby adapter for [complate](https://github.com/complate).\nSee https://github.com/complate/complate-sample-rails for example usage.\n\n## Usage in Rails\n\nFirst, add complate to your Gemfile:\n\n```\ngem \"complate\"\n```\n\nNow there are two options to call JSX/complate views from your controller:\n\n1. A `render` based approach which adds jsx files from your views folder\n   automatically and generates your complate bundle for you and\n2. a custom approach to render views from precompiled complate bundles.\n\n### Using `render`\n\nIn the `render` based approach complate-ruby manages your\nbundles for you. It expects the `faucet-pipeline` and `complate-stream`\nto be present in the `node_modules` directory of your app.\nAn minimal package.json for your app could look like:\n\n```json\n{\n  \"private\": true,\n  \"dependencies\": {\n    \"complate-stream\": \"^0.16.5\",\n    \"faucet-pipeline-jsx\": \"^1.1.1\"\n  }\n}\n```\n\nNow you can place views, layouts and partials ending with `.jsx`\nin your Rails view directories.\n\nYour view file must export a function returning a JSX-element.\nA simple view could look like:\n\n```jsx\nimport { createElement } from 'complate-stream';\nexport default ({ name }) =\u003e {\n  return \u003cspan\u003eHello {name}!\u003c/span\u003e;\n};\n```\n\nController instance variables will be passed\ninto the parameters object of your exported function as seen\nabove. So a compoller action calling the view above could look like:\n\n```ruby\nclass MyController \u003c ApplicationController\n  def greet\n    @name = \"World\"\n  end\nend\n```\n\n#### Chunking / streaming\n\nThe Rails `render` method makes it hard to implement real chunking.\nOne reason is the layout/partial support it implements. This\nadapter provides the `complate_stream` method to render a jsx/complate view\n**witout** layout and partial support but **with** real streaming\ninstead.\n\n```ruby\nclass MyController \u003c ApplicationController\n  include ActionController::Live\n  def greet\n    @name = \"World\"\n    complate_stream\n  end\nend\n```\n\n### Using `complate` precompiled bundles\n\nThis approach assumes that there already is some kind of complate\nbundle somewhere. This bundle should contain all your views\n(registered with `complate.registerView`), your components and\ncomplate-stream itself. The bundle should export an object\n`complate` with values\n\n* `render`: the `renderView` function bound to a renderer instance\n\n    ```javascript\n    renderer.renderView.bind(renderer)\n    ```\n\n* `safe`: complate's safe string function\n\nYou can call the following to render the \"NameOfView\" macro in\nyour controller actions with two parameters:\n\n```ruby\ncomplate(\"NameOfView\", param1: \"x\", param2: \"y\")\n```\n\nThis gem expect your bundle to be located in `dist/bundle.js`, but you can\nreconfigure that with `config.complate.bundle_path = '...'`\nor by using the option `:bundle_path` in the `complate` call:\n\n```ruby\ncomplate(\"MyView\", foo: \"bar\", bundle_path: Rails.root.join('other_bundle.js'))\n```\n\n## Helpers\n\ncomplate with Rails gives you access to rails helper methods. These are\naccessible via the global variable `rails`.\n\n```jsx\nimport { createElement } from 'complate-stream';\nexport default ({ name }) =\u003e {\n  return \u003cspan\u003e\u003ca href={rails.greet_url()}\u003eClick me!\u003c/a\u003e\u003c/span\u003e;\n};\n```\n\n## HTML safe strings\n\ncomplate will htmlencode all strings for you. It does **not** support\nRails HTML safe strings (`\"foo\".html_safe`) at the moment. So you'll\nhave to use complate's `safe` function to prevent complate from\nescaping Strings.\n\nThe exception are helper calls. Here the usage of Rails HTML safe\nStrings leads to automatically safe strings for complate too.\nIf you are using custom bundles you'll have to export complate's\n`safe` function to\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcomplate%2Fcomplate-ruby","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcomplate%2Fcomplate-ruby","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcomplate%2Fcomplate-ruby/lists"}