{"id":16068523,"url":"https://github.com/markbates/braai","last_synced_at":"2025-07-04T23:08:37.259Z","repository":{"id":4452893,"uuid":"5591450","full_name":"markbates/braai","owner":"markbates","description":"Fully Extensible Templates","archived":false,"fork":false,"pushed_at":"2013-03-12T14:16:02.000Z","size":217,"stargazers_count":3,"open_issues_count":0,"forks_count":4,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-02-07T18:51:34.354Z","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/markbates.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":"2012-08-28T20:11:42.000Z","updated_at":"2023-06-04T07:04:45.000Z","dependencies_parsed_at":"2022-09-20T23:22:11.190Z","dependency_job_id":null,"html_url":"https://github.com/markbates/braai","commit_stats":null,"previous_names":[],"tags_count":15,"template":false,"template_full_name":null,"purl":"pkg:github/markbates/braai","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/markbates%2Fbraai","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/markbates%2Fbraai/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/markbates%2Fbraai/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/markbates%2Fbraai/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/markbates","download_url":"https://codeload.github.com/markbates/braai/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/markbates%2Fbraai/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":263632058,"owners_count":23491530,"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-10-09T06:21:27.711Z","updated_at":"2025-07-04T23:08:37.228Z","avatar_url":"https://github.com/markbates.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Braai\n\nA fully extensible templating system. Sick and tired of all of those templating systems that force you to do things their way? Yeah, me too! Thankfully there's Braai. \nBraai let's you write your own Regular Expression matchers and then do whatever you'd like when the template is parsed! Sounds fun, doesn't it?\n\n## Installation\n\nAdd this line to your application's Gemfile:\n\n    gem 'braai'\n\nAnd then execute:\n\n    $ bundle\n\nOr install it yourself as:\n\n    $ gem install braai\n\n## Usage\n\n### Built-in Matchers\n\nBraai comes shipped with two simple matchers for you, but you can easily add your own.\n\nThe first matcher is a simple \u003ccode\u003eto_s\u003c/code\u003e matcher. It will match a single variable and then call \u003ccode\u003eto_s\u003c/code\u003e on it:\n\n```ruby\ntemplate = \"Hi {{ name }}!\"\nresponse = Braai::Template.new(template).render(name: \"Mark\")\nresponse.must_equal \"Hi Mark!\"\n```\n\nThe second matcher will call a method on the variable.\n\n```ruby\ntemplate = \"Hi {{ name.upcase }}!\"\nresponse = Braai::Template.new(template).render(name: \"Mark\")\nresponse.must_equal \"Hi MARK!\"\n```\n\n### Custom Matchers\n\nBraai let's you easily define your own matchers to do whatever you would like to do.\n\n```ruby\ntemplate = \"I'm {{ name }} and {{ mmm... bbq }}!\"\nBraai::Template.map(/({{\\s*mmm\\.\\.\\. bbq\\s*}})/i) do |template, key, matches|\n  \"Damn, I love BBQ!\"\nend\n\nBraai::Template.map(/({{\\s*name\\s*}})/i) do |template, key, matches|\n  template.attributes[:name].upcase\nend\n\nresponse = Braai::Template.new(template).render(name: \"mark\")\nresponse.must_equal \"I'm MARK and Damn, I love BBQ!!\"\n```\n\n### Conditional Logic\n\nBraai supports conditional logic with simple if statements (no support for comparisons yet).\n\n```ruby\ntemplate = '{{ product.name }}{{ if product.featured }}***{{ /if }}'\nfeatured_product = OpenStruct.new(name: 'Special Product', featured: true)\nregular_product = OpenStruct.new(name: 'Regular Product', featured: false)\n\nBraai::Template.new(template).render(product: featured_product).must_equal(\"Special Product***\")\nBraai::Template.new(template).render(product: regular_product).must_equal(\"Regular Product\")\n```\n\n### For Loops\n\nBraai also supports looping right out of the box.\n\n```ruby\ntemplate = \u003c\u003c-EOF\n\u003ch1\u003e{{ greet }}\u003c/h1\u003e\n\u003cul\u003e\n  {{ for product in products }}\n    \u003cli\u003e{{ product }}\u003c/li\u003e\n  {{ /for }}\n\u003c/ul\u003e\n\u003cdiv\u003e\n  {{ for food in foods }}\n    \u003cp\u003e{{ food }}\u003c/p\u003e\n  {{ /for }}\n\u003c/div\u003e\n\u003ch2\u003e{{greet.upcase}}\u003c/h2\u003e\nEOF\n\nres = Braai::Template.new(template).render(greet: \"mark\", products: %w{car boat truck}, foods: %w{apple orange})\nres.should match(\"\u003ch1\u003emark\u003c/h1\u003e\")\nres.should match(\"\u003cli\u003ecar\u003c/li\u003e\")\nres.should match(\"\u003cli\u003eboat\u003c/li\u003e\")\nres.should match(\"\u003cli\u003etruck\u003c/li\u003e\")\nres.should match(\"\u003cp\u003eapple\u003c/p\u003e\")\nres.should match(\"\u003cp\u003eorange\u003c/p\u003e\")\nres.should match(\"\u003ch2\u003eMARK\u003c/h2\u003e\")\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\n## Contributers\n\n* Mark Bates\n* Nick Plante\n* Sam Beam\n* Kevin Incorvia\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmarkbates%2Fbraai","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmarkbates%2Fbraai","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmarkbates%2Fbraai/lists"}