{"id":20010427,"url":"https://github.com/magynhard/curly_bracket_parser","last_synced_at":"2025-08-11T20:12:43.097Z","repository":{"id":37702141,"uuid":"288172544","full_name":"magynhard/curly_bracket_parser","owner":"magynhard","description":"Simple parser to replace variables inside templates/strings and files","archived":false,"fork":false,"pushed_at":"2023-05-08T18:50:16.000Z","size":61,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-08-11T05:49:56.908Z","etag":null,"topics":["parser","ruby","ruby-gem","variable-parser"],"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/magynhard.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-08-17T12:19:39.000Z","updated_at":"2022-08-08T04:09:35.000Z","dependencies_parsed_at":"2022-08-26T12:51:48.181Z","dependency_job_id":null,"html_url":"https://github.com/magynhard/curly_bracket_parser","commit_stats":null,"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"purl":"pkg:github/magynhard/curly_bracket_parser","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/magynhard%2Fcurly_bracket_parser","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/magynhard%2Fcurly_bracket_parser/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/magynhard%2Fcurly_bracket_parser/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/magynhard%2Fcurly_bracket_parser/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/magynhard","download_url":"https://codeload.github.com/magynhard/curly_bracket_parser/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/magynhard%2Fcurly_bracket_parser/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":269948859,"owners_count":24501821,"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-08-11T02:00:10.019Z","response_time":75,"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":["parser","ruby","ruby-gem","variable-parser"],"created_at":"2024-11-13T07:19:45.283Z","updated_at":"2025-08-11T20:12:43.070Z","avatar_url":"https://github.com/magynhard.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# curly_bracket_parser\n[![Gem](https://img.shields.io/gem/v/curly_bracket_parser?color=default\u0026style=plastic\u0026logo=ruby\u0026logoColor=red)](https://rubygems.org/gems/curly_bracket_parser)\n![downloads](https://img.shields.io/gem/dt/curly_bracket_parser?color=blue\u0026style=plastic)\n[![License: MIT](https://img.shields.io/badge/License-MIT-gold.svg?style=plastic\u0026logo=mit)](LICENSE)\n\n\u003e Ruby gem providing a simple parser to replace curly brackets `{{like_this}}` inside strings like URLs, texts or even files easily.\n\nAdditional support for build-in filters and custom filters make them more powerful. `{{example|my_filter}}`\n\nUsing [LuckyCase](https://github.com/magynhard/lucky_case), all its case formats are supported as filter by default.\n\n\n\n\n\n# Contents\n\n* [Installation](#installation)\n* [Usage examples](#usage)\n* [Documentation](#documentation)\n* [Contributing](#contributing)\n\n\n\n\n\u003ca name=\"installation\"\u003e\u003c/a\u003e\n## Installation\n\nAdd this line to your application's Gemfile:\n\n```ruby\ngem 'curly_bracket_parser'\n```\n\nAnd then execute:\n\n    $ bundle install\n\nOr install it yourself as:\n\n    $ gem install curly_bracket_parser\n    \n\n\u003ca name=\"usage\"\u003e\u003c/a\u003e\n## Usage examples\n\nYou can either parse variables inside strings or even directly in files.\n\n### Basic\n\n```ruby\n    url = \"https://my-domain.com/items/{{item_id}}\"\n    final_url = CurlyBracketParser.parse url, { item_id: 123 }\n    # =\u003e \"https://my-domain.com/items/123\"\n```\n\nNested variables are supported as well:\n```ruby\n    tmpl = \"This is my template with {{my_nested_variable}}\";\n    my_nested_variable = \"my {{nested}} variable\"; \n    parsed_tmpl = CurlyBracketParser.parse tmpl, { my_nested_variable: my_nested_variable, nested: 'pizza'}\n    # =\u003e \"This is my template with my pizza variable\"\n```\n\n\n\n### Filters\n\n```ruby\n    url = \"https://my-domain.com/catalog/{{item_name|snake_case}}\"\n    final_url = CurlyBracketParser.parse url, { item_name: 'MegaSuperItem' }\n    # =\u003e \"https://my-domain.com/catalog/mega_super_item\"\n```\n\nFor a list of built-in filters visit [LuckyCase](https://github.com/magynhard/lucky_case).\n\n#### Define your custom filter\n\n```ruby\n    CurlyBracketParser.register_filter('7times') do |string|\n      string.to_s * 7\n    end\n\n    text = \"Paul went out and screamed: A{{scream|7times}}h\"\n    final_text = CurlyBracketParser.parse text, { scream: 'a' }\n    # =\u003e \"Paul went out and screamed: Aaaaaaaah\"\n```\n\n\n### Value variables\n\nFor special cases you can directly define or set variables inside the template - usually it does only make sense, if you combine them with custom filters.\n\nYou can either use quotes to define a string or numbers (integer or floating point) directly.\n\nEmpty values are possible as well. They are equal to a empty string.\n\n```ruby\n    tmpl = %Q(This is a {{'string'|pascal_case}} and today is {{\"today\"|date_filter}}. Peter is {{'1990-10-05'|iso_date_age}} years old. His girlfriends name is {{girl|pascal_case}} and she is {{16|double_number}} years old. This article has been written at {{|date_now_formatted}}`)\n    parsed = CurlyBracketParser.parse tmpl, { girl: \"anna\" }\n    # =\u003e \"This is a String and today is 2022-06-27. Peter is 32 years old. His girlfriends name is Anna and she is 32 years old. This article has been written at 6/28/2022, 12:46:40 PM.\"\n```\n\n\n### Files\n\n\u003cins\u003etest.html\u003c/ins\u003e\n```html\n\u003ch1\u003e{{title|sentence_case}}\u003c/h1\u003e\n```\n\n```ruby\n    parsed_file = CurlyBracketParser.parse_file './test.html', { title: 'WelcomeAtHome' }\n    # =\u003e \"\u003ch1\u003eWelcome at home\u003c/h1\u003e\"\n```\n\nUse `#parse_file!` instead to write the parsed string directly into the file!\n\n### Default variables\n\nYou can define default variables, which will be replaced automatically without passing them by parameters, but can be overwritten with parameters.\n\nBecause of providing blocks, your variables can dynamically depend on other states (e.g. current date).\n\n```ruby\n    CurlyBracketParser.register_default_var('version') do\n      '1.0.2'\n    end\n\n    text = \"You are running version {{version}}\"\n    CurlyBracketParser.parse text\n    # =\u003e \"You are running version 1.0.2\"\n    CurlyBracketParser.parse text, { version: '0.7.0' }\n    # =\u003e \"You are running version 0.7.0\"\n```\n\n\n\n\n\u003ca name=\"documentation\"\u003e\u003c/a\u003e\n## Documentation\nCheck out the doc at RubyDoc\n\u003ca href=\"https://www.rubydoc.info/gems/curly_bracket_parser\"\u003ehttps://www.rubydoc.info/gems/curly_bracket_parser\u003c/a\u003e\n\n\n\n\n\n\u003ca name=\"contributing\"\u003e\u003c/a\u003e\n## Contributing\n\nBug reports and pull requests are welcome on GitHub at https://github.com/magynhard/curly_bracket_parser. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmagynhard%2Fcurly_bracket_parser","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmagynhard%2Fcurly_bracket_parser","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmagynhard%2Fcurly_bracket_parser/lists"}