{"id":15431605,"url":"https://github.com/crawler/stimulus_tag_helper","last_synced_at":"2025-07-06T01:07:12.985Z","repository":{"id":39205471,"uuid":"379551624","full_name":"crawler/stimulus_tag_helper","owner":"crawler","description":"A form_for like, compact and elegant way to define stimulus tag attributes in your views.","archived":false,"fork":false,"pushed_at":"2024-10-08T20:13:47.000Z","size":64,"stargazers_count":28,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-06-11T10:05:39.053Z","etag":null,"topics":["rails","ruby","ruby-gem","ruby-on-rails","stimulus","stimulus-reflex","stimulusjs"],"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/crawler.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.txt","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":"2021-06-23T09:38:09.000Z","updated_at":"2025-05-12T01:55:19.000Z","dependencies_parsed_at":"2025-01-28T19:34:37.563Z","dependency_job_id":"b918c9d2-5018-4062-8271-bd87634ca2e4","html_url":"https://github.com/crawler/stimulus_tag_helper","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/crawler/stimulus_tag_helper","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/crawler%2Fstimulus_tag_helper","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/crawler%2Fstimulus_tag_helper/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/crawler%2Fstimulus_tag_helper/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/crawler%2Fstimulus_tag_helper/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/crawler","download_url":"https://codeload.github.com/crawler/stimulus_tag_helper/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/crawler%2Fstimulus_tag_helper/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":259812625,"owners_count":22915171,"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":["rails","ruby","ruby-gem","ruby-on-rails","stimulus","stimulus-reflex","stimulusjs"],"created_at":"2024-10-01T18:23:26.743Z","updated_at":"2025-07-06T01:07:12.919Z","avatar_url":"https://github.com/crawler.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# stimulus_tag_helper\n\n[![Rubocop](https://github.com/crawler/stimulus_tag_helper/actions/workflows/rubocop.yml/badge.svg)](https://github.com/crawler/stimulus_tag_helper/actions/workflows/rubocop.yml)\n[![Tests](https://github.com/crawler/stimulus_tag_helper/actions/workflows/test.yml/badge.svg)](https://github.com/crawler/stimulus_tag_helper/actions/workflows/test.yml)\n[![Ruby Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://github.com/testdouble/standard)\n[![Gem](https://img.shields.io/gem/v/stimulus_tag_helper.svg)](https://rubygems.org/gems/stimulus_tag_helper)\n\n## ~~WARING!~~\n\n~~This gem is in the proof of concept stage. I made it for myself, and it is not yet covered with tests and documentation.~~\n\n🎉 After around a year from initial publication, the helper is pretty useful and simple enough to be stable and compatible with different Ruby/Rails versions. So I decided to cover it with tests and add fancy badges.\n\nIf Russia has not dropped a nuclear bomb on Kyiv then the repo is still maintained by me.\n\n## Description\n\nThe stimulusjs is a great js framework for the HTML that you already have, but once you start using it the HTML became wordier, as you need to extend it with more attributes that you already have. So I made this even more modest than the stimulus helper.\n\nSometimes it makes the template cleaner, sometimes it is not. It's up to you when to use it.\n\nHelper matches Stimulus 2.0+ requirements. You can mix attributes of multiple controllers in a single element or the tag helper. In the end, the stimulus helpers return is a simple Hash.\n\n---\n\n- [Compatibility](#compatibility)\n- [Quick start](#quick-start)\n- [Examples](#examples)\n- [Support](#support)\n- [License](#license)\n- [Code of conduct](#code-of-conduct)\n- [Contribution guide](#contribution-guide)\n\n## Compatibility\n\n**Ruby:** 3.1, 3.0, 2.7; **Rails:** edge, 7.0, 6.1, 6.0\n\n## Quick start\n\n```ruby\ngem `stimulus_tag_helper`\n```\n\n### In the Rails Controller\n\n```ruby\nhelper StimulusTagHelper\n```\n\n### In the ViewComponent\n\n```ruby\ninclude StimulusTagHelper\n```\n\n## Examples\n\n### The controller from the stimulusjs homepage\n\n**Slim Lang:**\n```slim\n= stimulus_controller(\"hello\", tag: \"div\") do |sc|\n  = text_field_tag('', '', **sc.target(\"name\"))\n  = button_tag('Greet', type: 'button', **sc.action(\"click-\u003egreet\"))\n  span[*sc.target(\"output\")]\n```\n\n**Output:**\n\n```html\n\u003cdiv data-controller=\"hello\"\u003e\n  \u003cinput type=\"text\" name=\"\" id=\"\" value=\"\" data-hello-target=\"name\" /\u003e\n  \u003cbutton name=\"button\" type=\"button\" data-action=\"click-\u003ehello#greet\"\u003eGreet\u003c/button\u003e\n  \u003cspan data-hello-target=\"output\"\u003e\u003c/span\u003e\n\u003c/div\u003e\n```\n\n*To support nesting, and the stimulus 2.0 attributes notation, the actions, and the targets are prefixed with the controller name*\n\n\n### Initialize the builder and use the controller attribute later\n\n**Slim Lang**\n\n```slim\n= stimulus_controller(\"slideshow\") do |sc|\n  div[*sc.controller_attribute]\n    = button_tag ' ← ', type: 'button', **sc.action(\"previous\")\n    = button_tag ' → ', type: 'button', **sc.action(\"next\")\n    div[*sc.target(\"slide\")] 🐵\n    div[*sc.target(\"slide\")] 🙈\n    div[*sc.target(\"slide\")] 🙉\n    div[*sc.target(\"slide\")] 🙊\n```\n\n**Output:**\n\n```html\n\u003cdiv data-controller=\"slideshow\"\u003e\n  \u003cbutton name=\"button\" type=\"button\" data-action=\"slideshow#previous\"\u003e ← \u003c/button\u003e\n  \u003cbutton name=\"button\" type=\"button\" data-action=\"slideshow#next\"\u003e → \u003c/button\u003e\n  \u003cdiv data-slideshow-target=\"slide\"\u003e🐵\u003c/div\u003e\n  \u003cdiv data-slideshow-target=\"slide\"\u003e🙈\u003c/div\u003e\n  \u003cdiv data-slideshow-target=\"slide\"\u003e🙉\u003c/div\u003e\n  \u003cdiv data-slideshow-target=\"slide\"\u003e🙊\u003c/div\u003e\n\u003c/div\u003e\n```\n\n### Nested controllers example\n\n**Plain Ruby:**\n\n```ruby\nstimulus_controller(:effects) do |ec|\n  stimulus_controller(\n    :clipboard, tag: :div, **ec.controller_property.merge(ec.action_property(\"clipboard:copy-\u003eflash\"))\n  ) do |cc|\n    safe_join([\n      \"PIN: \",\n      tag.input(**cc.attributes(target: \"source\"), type: \"text\", value: \"1234\", readonly: true),\n      tag.button(**cc.action(\"copy\")) { \"Copy to Clipboard\" }\n    ])\n  end\nend\n```\n\n**Output:**\n\n```html\n\u003cdiv data-controller=\"clipboard effects\" data-action=\"clipboard:copy-\u003eeffects#flash\"\u003e\n  PIN: \u003cinput data-clipboard-target=\"source\" type=\"text\" value=\"1234\" readonly=\"readonly\"\u003e\n  \u003cbutton data-action=\"clipboard#copy\"\u003eCopy to Clipboard\u003c/button\u003e\n\u003c/div\u003e\n```\n\n## Support\n\nIf you want to report a bug or have ideas, feedback, or questions about the gem, [let me know via GitHub issues](https://github.com/crawler/stimulus_tag_helper/issues/new) and I will do my best to provide a helpful answer. Happy hacking!\n\n## License\n\nThe gem is available as open-source under the terms of the [MIT License](LICENSE.txt).\n\n## Code of conduct\n\nEveryone interacting in this project’s codebases, issue trackers, chat rooms, and mailing lists is expected to follow\nthe [code of conduct](CODE_OF_CONDUCT.md).\n\n## Contribution guide\n\nPull requests are welcome!\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcrawler%2Fstimulus_tag_helper","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcrawler%2Fstimulus_tag_helper","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcrawler%2Fstimulus_tag_helper/lists"}