# curly_bracket_parser Ruby gem with simple parser to replace curly brackets `{{like_this}}` inside strings like URLs, texts or even files easily. Additional support for build-in filters and custom filters make them more powerful. `{{example|my_filter}}` Using [LuckyCase](https://github.com/magynhard/lucky_case), all its case formats are supported as filter. # Contents * [Installation](#installation) * [Usage](#usage) * [Documentation](#documentation) * [Contributing](#contributing) ## Installation Add this line to your application's Gemfile: ```ruby gem 'curly_bracket_parser' ``` And then execute: $ bundle install Or install it yourself as: $ gem install curly_bracket_parser ## Usage examples You can either parse variables inside strings or even directly in files. ### Basic ```ruby url = "https://my-domain.com/items/{{item_id}}" final_url = CurlyBracketParser.parse url, item_id: 123 # => "https://my-domain.com/items/123" ``` ### Filters ```ruby url = "https://my-domain.com/catalog/{{item_name|snake_case}}" final_url = CurlyBracketParser.parse url, item_name: 'MegaSuperItem' # => "https://my-domain.com/catalog/mega_super_item" ``` For a list of built-in filters visit [LuckyCase](https://github.com/magynhard/lucky_case). #### Define your custom filter ```ruby CurlyBracketParser.register_filter('7times') do |string| string.to_s * 7 end text = "Paul went out and screamed: A{{scream|7times}}h" final_text = CurlyBracketParser.parse text, scream: 'a' # => "Paul went out and screamed: Aaaaaaaah" ``` ### Files test.html ```html