{"id":13878378,"url":"https://github.com/marcoroth/phlexing","last_synced_at":"2025-04-13T02:16:41.246Z","repository":{"id":60073707,"uuid":"538986670","full_name":"marcoroth/phlexing","owner":"marcoroth","description":"Simple ERB to Phlex converter","archived":false,"fork":false,"pushed_at":"2024-10-28T18:47:10.000Z","size":1607,"stargazers_count":83,"open_issues_count":20,"forks_count":11,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-10-29T14:29:11.530Z","etag":null,"topics":["erb","hotwire","html","phlex","rails","ruby"],"latest_commit_sha":null,"homepage":"https://phlexing.fun","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/marcoroth.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},"funding":{"github":"marcoroth"}},"created_at":"2022-09-20T12:49:52.000Z","updated_at":"2024-10-22T04:29:06.000Z","dependencies_parsed_at":"2023-10-18T19:36:00.205Z","dependency_job_id":"07e3f870-4e28-4687-a19f-6257d179503d","html_url":"https://github.com/marcoroth/phlexing","commit_stats":{"total_commits":498,"total_committers":9,"mean_commits":"55.333333333333336","dds":0.4257028112449799,"last_synced_commit":"6d8f7797ff2da184e62b83e8e497d92589f60bfa"},"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marcoroth%2Fphlexing","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marcoroth%2Fphlexing/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marcoroth%2Fphlexing/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marcoroth%2Fphlexing/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/marcoroth","download_url":"https://codeload.github.com/marcoroth/phlexing/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248654104,"owners_count":21140237,"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":["erb","hotwire","html","phlex","rails","ruby"],"created_at":"2024-08-06T08:01:47.807Z","updated_at":"2025-04-13T02:16:41.209Z","avatar_url":"https://github.com/marcoroth.png","language":"Ruby","readme":"# Phlexing\n\n[![Tests](https://github.com/marcoroth/phlexing/actions/workflows/tests.yml/badge.svg)](https://github.com/marcoroth/phlexing/actions/workflows/tests.yml)\n[![Rubocop](https://github.com/marcoroth/phlexing/actions/workflows/rubocop.yml/badge.svg)](https://github.com/marcoroth/phlexing/actions/workflows/rubocop.yml)\n\nA simple ERB to [Phlex](https://www.phlex.fun) Converter.\n\n\u003ca href=\"https://phlexing.fun\"\u003e\n  \u003cimg src=\"./screenshot.png\" alt=\"Phlexing Screenshot\"\u003e\n\u003c/a\u003e\n\n## Website\n\nA hosted version of the converter is running at [https://phlexing.fun](https://phlexing.fun).\n\n\n## Using the gem\n\n### Installation\n\nInstall the gem and add to the application's Gemfile by executing:\n\n    $ bundle add phlexing\n\nIf bundler is not being used to manage dependencies, install the gem by executing:\n\n    $ gem install phlexing\n\n### Basic Usage\n\n```ruby\nrequire \"phlexing\"\n\nPhlexing::Converter.convert(%(\u003ch1 class=\"title\"\u003eHello World\u003c/h1\u003e))\n```\n\n##### Output\n\n```ruby\nh1(class: \"title\") { \"Hello World\" }\n```\n\n### Converter Options\n\n| Option | Type | Default Value | Description |\n| --- | --- | --- | --- |\n| `whitespace` | `Boolean` | `true` | Generate whitespace in and around HTML block elements. |\n| `component` | `Boolean` | `false` | Generate a Phlex class with a `view_template` method around your input. |\n| `component_name` | `String` | `\"Component\"` | The name of your Phlex class. |\n| `parent_component` | `String` | `\"Phlex::HTML\"` | The name of the parent class your Phlex class will inherit from. |\n| `svg_param` | `String` | `\"s\"` | The name of the block argument Phlex will use to generate SVG-specific elements. |\n| `template_name` | `String` | `\"view_template\"` | The name of the generated template method in your Phlex class. |\n\n### Multi-line HTML\n\n```ruby\n\nPhlexing::Converter.convert(\u003c\u003c~HTML)\n  \u003c% @articles.each do |article| %\u003e\n    \u003ch1\u003e\u003c%= article.title %\u003e\u003c/h1\u003e\n  \u003c% end %\u003e\nHTML\n```\n\n##### Output\n\n```ruby\n@articles.each { |article| h1 { article.title } }\n```\n\n### Component class\n\n```ruby\nPhlexing::Converter.convert(\u003c\u003c~HTML, component: true)\n  \u003ch1\u003e\u003c%= @user.name %\u003e\u003c/h1\u003e\n\n  \u003cp\u003e\u003c%= posts.count %\u003e Posts\u003c/p\u003e\nHTML\n```\n\n##### Output\n```ruby\nclass Component \u003c Phlex::HTML\n  attr_accessor :posts\n\n  def initialize(posts:, user:)\n    @posts = posts\n    @user = user\n  end\n\n  def view_template\n    h1 { @user.name }\n\n    p do\n      text posts.count\n      text %( Posts)\n    end\n  end\nend\n```\n\n### Rails Helpers\n\n```ruby\nPhlexing::Converter.convert(%(\u003c%= link_to \"Home\", root_path %\u003e), component: true)\n```\n\n##### Output\n```ruby\nclass Component \u003c Phlex::HTML\n  include Phlex::Rails::Helpers::LinkTo\n  include Phlex::Rails::Helpers::Routes\n\n  def view_template\n    link_to \"Home\", root_path\n  end\nend\n```\n\n### Private component methods\n\n```ruby\nPhlexing::Converter.convert(%(\u003c% if active? %\u003eActive\u003c% else %\u003eInactive\u003c% end %\u003e), component: true)\n```\n\n##### Output\n```ruby\nclass Component \u003c Phlex::HTML\n  def view_template\n    if active?\n      text \"Active\"\n    else\n      text \"Inactive\"\n    end\n  end\n\n  private\n\n  def active?(*args, **kwargs)\n    # TODO: Implement me\n  end\nend\n```\n\n### ERB Attribute interpolation\n\n```ruby\nPhlexing::Converter.convert(%(\u003cdiv style=\"background: \u003c%= active? ? \"green\" : \"gray\" %\u003e\"\u003e\u003c/div\u003e))\n```\n\n##### Output\n\n```ruby\ndiv(style: %(background: #{active? ? \"green\" : \"gray\"}))\n```\n\n### Development\n\nAfter checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.\n\nTo install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).\n\n### Contributing\n\nBug reports and pull requests are welcome on GitHub at https://github.com/marcoroth/phlexing. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/marcoroth/phlexing/blob/master/CODE_OF_CONDUCT.md).\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### Code of Conduct\n\nEveryone interacting in the Phlexing project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/marcoroth/phlexing/blob/master/CODE_OF_CONDUCT.md).\n","funding_links":["https://github.com/sponsors/marcoroth"],"categories":["Ruby","Utilities \u0026 Tools"],"sub_categories":["Libraries"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmarcoroth%2Fphlexing","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmarcoroth%2Fphlexing","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmarcoroth%2Fphlexing/lists"}