{"id":19708727,"url":"https://github.com/nlight/css-class-string","last_synced_at":"2026-03-01T16:04:25.215Z","repository":{"id":65410247,"uuid":"20638457","full_name":"nLight/css-class-string","owner":"nLight","description":"Helper for creating css class strings inspired by ReactJS classSet","archived":false,"fork":false,"pushed_at":"2014-08-17T20:21:58.000Z","size":226,"stargazers_count":22,"open_issues_count":0,"forks_count":2,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-21T12:22:37.884Z","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/nLight.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":"2014-06-09T07:44:36.000Z","updated_at":"2025-02-20T21:29:16.000Z","dependencies_parsed_at":"2023-01-23T10:54:58.026Z","dependency_job_id":null,"html_url":"https://github.com/nLight/css-class-string","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nLight%2Fcss-class-string","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nLight%2Fcss-class-string/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nLight%2Fcss-class-string/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nLight%2Fcss-class-string/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nLight","download_url":"https://codeload.github.com/nLight/css-class-string/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251549124,"owners_count":21607355,"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-11-11T21:44:27.324Z","updated_at":"2026-03-01T16:04:25.171Z","avatar_url":"https://github.com/nLight.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# CssClassString\n\nHelper for creating css class strings inspired by ReactJS classSet\n\n- Pass bare arguments for default classes\n- Pass hash of `class =\u003e \u003cboolean\u003e` for conditional classes\n- Use array with two classes as a `key` and first will be used for truthy and second for falsey value `[:true?, :false?] =\u003e \u003cboolean\u003e`\n\n## Installation\n\nAdd this line to your application's Gemfile:\n\n    gem 'css-class-string'\n\n## Usage\n\n```haml\n  // @boolvalue = true\n  %span{class: class_string({some: true, classy: false, [:truthy, :falsy] =\u003e @boolvalue})}\n  // equal to\n  %span{class: class_string('some', falsy: false, [:truthy, :falsy] =\u003e @boolvalue)}\n  // =\u003e \u003cspan class=\"some truthy\"\u003e\u003c/span\u003e\n```\n\n```html+erb\n  \u003c!-- @boolvalue = false --\u003e\n  \u003cspan class=\"\u003c%= class_string({some: true, classy: true, [:truthy, :falsy] =\u003e @boolvalue} %\u003e\"\u003e\n  \u003c!-- equal to --\u003e\n  \u003cspan class=\"\u003c%= class_string('some', 'classy', [:truthy, :falsy] =\u003e @boolvalue %\u003e\"\u003e\n  \u003c!-- =\u003e \u003cspan class=\"some classy falsy\"\u003e\u003c/span\u003e --\u003e\n```\n\nOutside a view\n\n```ruby\nCssClassString::Helper.new({}).to_s\n```\n\n## Contributing\n\n1. Fork it\n2. Create your feature branch (`git checkout -b my-new-feature`)\n3. Commit your changes (`git commit -am 'Add some feature'`)\n4. Push to the branch (`git push origin my-new-feature`)\n5. Create new Pull Request\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnlight%2Fcss-class-string","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnlight%2Fcss-class-string","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnlight%2Fcss-class-string/lists"}