{"id":15512756,"url":"https://github.com/chamnap/themes_on_rails","last_synced_at":"2025-10-12T09:31:44.715Z","repository":{"id":11898568,"uuid":"14461926","full_name":"chamnap/themes_on_rails","owner":"chamnap","description":"Adds multi themes support to your Rails 3/4/5 application","archived":false,"fork":false,"pushed_at":"2023-07-11T18:22:09.000Z","size":185,"stargazers_count":217,"open_issues_count":12,"forks_count":86,"subscribers_count":18,"default_branch":"master","last_synced_at":"2025-10-09T23:15:54.513Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://rubygems.org/gems/themes_on_rails","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/chamnap.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2013-11-17T05:46:27.000Z","updated_at":"2025-04-26T15:37:49.000Z","dependencies_parsed_at":"2024-06-18T18:42:49.263Z","dependency_job_id":"d455dc57-6d8c-4cf4-8b22-4593755faf07","html_url":"https://github.com/chamnap/themes_on_rails","commit_stats":null,"previous_names":["yoolk/themes_on_rails"],"tags_count":7,"template":false,"template_full_name":null,"purl":"pkg:github/chamnap/themes_on_rails","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chamnap%2Fthemes_on_rails","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chamnap%2Fthemes_on_rails/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chamnap%2Fthemes_on_rails/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chamnap%2Fthemes_on_rails/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/chamnap","download_url":"https://codeload.github.com/chamnap/themes_on_rails/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chamnap%2Fthemes_on_rails/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279010939,"owners_count":26084837,"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-10-12T02:00:06.719Z","response_time":53,"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-10-02T09:53:50.216Z","updated_at":"2025-10-12T09:31:44.177Z","avatar_url":"https://github.com/chamnap.png","language":"Ruby","funding_links":[],"categories":["Ruby"],"sub_categories":[],"readme":"# ThemesOnRails [![Build Status](https://travis-ci.org/yoolk/themes_on_rails.png?branch=master)](https://travis-ci.org/yoolk/themes_on_rails) [![Dependency Status](https://gemnasium.com/yoolk/themes_on_rails.png)](https://gemnasium.com/yoolk/themes_on_rails) [![Code Climate](https://codeclimate.com/github/yoolk/themes_on_rails.png)](https://codeclimate.com/github/yoolk/themes_on_rails) [![Coverage Status](https://coveralls.io/repos/yoolk/themes_on_rails/badge.png?branch=master)](https://coveralls.io/r/yoolk/themes_on_rails?branch=master) [![Gem Version](https://badge.fury.io/rb/themes_on_rails.png)](http://badge.fury.io/rb/themes_on_rails)\n\n## Installation\n\nThe simplest way to install is to use Bundler.\n\nAdd this gem to your Gemfile:\n\n    gem 'themes_on_rails'\n\nIf you want to use `themes_on_rails` with `liquid` template, add one more gem to your Gemfile:\n\n    gem 'liquid-rails'\n\nThen, use Bundler to install the gem and its dependencies:\n\n    $ bundle install\n\n## Usage\n\nA theme is composed of three things:\n\n  1. Assets: images, javascripts, stylesheets\n  2. Views: templates and layouts (erb, haml, or other template engines)\n  3. Locales: locales files if any\n\n### Generator\n\nTo generate theme inside your app:\n\n    $ rails g themes_on_rails:theme theme_name\n\n\u003cpre\u003e\napp/\n  themes/\n    [theme_name]/\n      assets/\n        images/\n          [theme_name]/\n        stylesheets/\n          [theme_name]/\n            all.css\n        javascripts/\n          [theme_name]/\n            all.js\n      views/\n        layouts/\n          [theme_name].html.erb\n      locales/\n\u003c/pre\u003e\n\nAfter you invoke the above command, make sure you restart your rails process.\n\nIt's best advisable to namespace your assets directory so that it won't conflict with assets in other themes.\n\n```ruby\nimage_tag              'theme_a/logo.png' # =\u003e app/themes/theme_a/assets/images/theme_a/logo.png\njavascript_include_tag 'theme_a/all'      # =\u003e app/themes/theme_a/assets/javascripts/theme_a/all.js\nstylesheet_link_tag    'theme_a/all'      # =\u003e app/themes/theme_a/assets/stylesheets/theme_a/all.css\n```\n\nThere is an example app at https://github.com/chamnap/themes_on_rails_example.\n\n### Controller\n\nYou can set theme in your controllers by using the `theme` declaration. For example:\n\n```ruby\nclass HomeController \u003c ApplicationController\n  theme 'basic'\n\n  def index\n    ...\n  end\nend\n```\n\nWith this declaration, all of the views rendered by the home controller will use `app/themes/basic/views/home/index.html.erb` as its templates and use `app/themes/basic/views/layouts/basic.html.erb`.\n\nYou can use a symbol to defer the choice of theme until a request is processed:\n\n```ruby\nclass HomeController \u003c ApplicationController\n  theme :theme_resolver\n\n  def index\n    ...\n  end\n\n  private\n\n    def theme_resolver\n      params[:theme].presence || 'professional'\n    end\nend\n```\n\nNow, if there is a `params[:theme]`, it will use that theme. Otherwise, it will use **professional** theme.\n\nYou can even use an inline method, such as a **Proc**, to determine the theme. For example, if you pass a **Proc** object, the block you give the **Proc** will be given the controller instance, so the theme can be determined based on the current request:\n\n```ruby\nclass HomeController \u003c ApplicationController\n  theme Proc.new { |controller| controller.params[:theme].presence || 'professional' }\nend\n```\n\nTheme specified at the controller level support the `:only` and `:except` options. These options take either a method name, or an array of method names, corresponding to method names within the controller:\n\n```ruby\nclass HomeController \u003c ApplicationController\n  theme 'basic', except: [:rss]\nend\n```\n\nWith this declaration, the **basic** theme would be used for everything but the `rss` index methods.\n\n## Authors\n\n* [Chamnap Chhorn](https://github.com/chamnap)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchamnap%2Fthemes_on_rails","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fchamnap%2Fthemes_on_rails","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchamnap%2Fthemes_on_rails/lists"}