{"id":13879052,"url":"https://github.com/nebulab/renderful","last_synced_at":"2025-04-22T10:44:04.769Z","repository":{"id":56891792,"uuid":"190914402","full_name":"nebulab/renderful","owner":"nebulab","description":"A Ruby rendering engine for headless CMSs, with support for caching and Ruby on Rails.","archived":false,"fork":false,"pushed_at":"2020-04-24T07:58:17.000Z","size":147,"stargazers_count":5,"open_issues_count":6,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-22T10:43:53.053Z","etag":null,"topics":["component","contentful","rails","rendering","ruby","ui"],"latest_commit_sha":null,"homepage":"","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/nebulab.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"MIT-LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-06-08T17:09:08.000Z","updated_at":"2024-07-27T13:41:49.000Z","dependencies_parsed_at":"2022-08-21T00:20:29.598Z","dependency_job_id":null,"html_url":"https://github.com/nebulab/renderful","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nebulab%2Frenderful","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nebulab%2Frenderful/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nebulab%2Frenderful/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nebulab%2Frenderful/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nebulab","download_url":"https://codeload.github.com/nebulab/renderful/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250222453,"owners_count":21394870,"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":["component","contentful","rails","rendering","ruby","ui"],"created_at":"2024-08-06T08:02:08.201Z","updated_at":"2025-04-22T10:44:04.738Z","avatar_url":"https://github.com/nebulab.png","language":"Ruby","funding_links":[],"categories":["Ruby"],"sub_categories":[],"readme":"# Renderful\n\n[![CircleCI](https://circleci.com/gh/nebulab/renderful.svg?style=svg)](https://circleci.com/gh/nebulab/renderful)\n\nWelcome! Renderful is a rendering engine for headless CMSs. It allows you to map your content types\nto Ruby objects that take care of rendering your content.\n\n## Installation\n\nAdd this line to your application's Gemfile:\n\n```ruby\ngem 'renderful'\n```\n\nAnd then execute:\n\n```console\n$ bundle\n```\n\nOr install it yourself as:\n\n```console\n$ gem install renderful\n```\n\nOnce you have installed the gem, you can configure it like this:\n\n```ruby\nRenderfulClient = Renderful::Client.new(\n  provider: Renderful::Provider::DummyCms.new(api_key: 'secretApiKey'), # see \"Providers\"\n  components: {\n    'jumbotron' =\u003e JumbotronComponent,\n  },\n)\n```\n\n## Usage\n\nSuppose you have the `jumbotron` content type in your Contentful space. This content type has the\n`title` and `content` fields, both strings.\n\nLet's create the `app/components/jumbotron_component.rb` file:\n\n```ruby\nclass JumbotronComponent \u003c Renderful::Component\n  def render\n    \u003c\u003c~HTML\n      \u003cdiv class=\"jumbotron\"\u003e\n        \u003ch1 class=\"display-4\"\u003e#{ entry.title }\u003c/h1\u003e\n        \u003cp class=\"lead\"\u003e#{ entry.content }\u003c/p\u003e\n      \u003c/div\u003e\n    HTML\n  end\nend\n```\n\nYou can now render the component like this:\n\n```ruby\nRenderfulClient.render('my_entry_id')\n```\n\n### Caching\n\nYou can easily cache the output of your components. A Redis cache implementation is included out of\nthe box. Here's an example:\n\n```ruby\nRenderfulClient = Renderful.new(\n  cache: Renderful::Cache::Redis.new(Redis.new(url: 'redis://localhost:6379')),\n  # ...\n)\n```\n\nIf you are using Rails and want to use the Rails cache store for Renderful, you can simply pass\n`Rails.cache`, which responds to the expected interface:\n\n```ruby\nRenderfulClient = Renderful.new(ful,\n  cache: Rails.cache,\n  # ...\n)\n```\n\n#### Cache invalidation\n\nThe best way to invalidate the cache is through [webhooks](https://www.contentful.com/developers/docs/concepts/webhooks/).\n\nRenderful ships with a framework-agnostic webhook processor you can use to automatically invalidate\nthe cache for all updated content:\n\n```ruby\nRenderfulClient.invalidate_cache_from_webhook(json_body)\n```\n\nThis is how you could use it in a Rails controller:\n\n```ruby\nclass WebhooksController \u003c ApplicationController\n  skip_before_action :verify_authenticity_token\n\n  def create\n    RenderfulClient.invalidate_cache_from_webhook(request.raw_post)\n    head :no_content\n  end\nend\n```\n\nThe cache invalidator will not only invalidate the cache for the entry that has been updated, but\nalso for any entries linking to it, so that they are re-rendered. This is very useful, for instance,\nif you have a `Page` entry type that contains references to many UI components - when one of the\ncomponents is updated, you want the page to be re-rendered.\n\n### ViewComponent support\n\nRenderful integrates nicely with [ViewComponent](https://github.com/github/view_component) for\nrendering your components:\n\n```ruby\nRenderfulClient = Renderful::Client.new(\n  components: {\n    'jumbotron' =\u003e JumbotronComponent, # JumbotronComponent inherits from ViewComponent::Base\n  },\n)\n``` \n\nHowever, keep in mind you will now have to pass a view context when rendering them:\n\n```ruby\nRenderfulClient.render('my_entry_id', view_context: view_context)\n```\n\n## Providers\n\n### Contentful\n\nIn order to integrate with Contentful, you will first need to add the `contentful` gem to your\nGemfile:\n\n```ruby\ngem 'contentful'\n```\n\nNow make sure to install it:\n\n```console\n$ bundle install\n```\n\nFinally, initialize Renderful with the Contentful provider:\n\n```ruby\nRenderfulClient = Renderful::Client.new(\n  provider: Renderful::Provider::Contentful.new(\n    contentful: Contentful::Client.new(\n      space: 'cfexampleapi',\n      access_token: 'b4c0n73n7fu1',\n    )\n  )\n)\n```\n\nYou can now render your Contentful entries via Renderful:\n\n```ruby\nRenderfulClient.render('your_entry_id')\n```\n\n### Prismic\n\nIn order to integrate with Prismic, you will first need to add the `prismic.io` gem to your Gemfile:\n\n```ruby\ngem 'prismic.io', require: 'prismic'\n```\n\nNow make sure to install it:\n\n```console\n$ bundle install\n```\n\nFinally, initialize Renderful with the Prismic provider:\n\n```ruby\nRenderfulClient = Renderful::Client.new(\n  provider: Renderful::Provider::Prismic.new(\n    prismic: Prismic.api('https://yourendpoint.prismic.io/api', 'your_access_token')\n  )\n)\n```\n\nYou can now render your Prismic documents via Renderful:\n\n```ruby\nRenderfulClient.render('your_entry_id')\n```\n\nNOTE: Due to limitations in Prismic's API, cache invalidation for Prismic will invalidate all your\ncomponents. Depending on how often you update your content, you may want to disable caching entirely\nif you are using Prismic.\n\n## Development\n\nAfter checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run\nthe tests. You can also run `bin/console` for an interactive prompt that will allow you to\nexperiment.\n\nTo install this gem onto your local machine, run `bundle exec rake install`. To release a new\nversion, update the version number in `version.rb`, and then run `bundle exec rake release`, which\nwill create a git tag for the version, push git commits and tags, and push the `.gem` file to\n[rubygems.org](https://rubygems.org).\n\n## Contributing\n\nBug reports and pull requests are welcome on GitHub at https://github.com/nebulab/renderful.\n\n## License\n\nThe gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).\n\n## Credits\n\nRenderful was originally developed by [Nebulab](https://nebulab.it) and sponsored by\n[Bolt Threads](https://www.boltthreads.com). It is currently maintained by Nebulab.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnebulab%2Frenderful","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnebulab%2Frenderful","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnebulab%2Frenderful/lists"}