erbr makes the bound and rendering of a given template inside a given layout allowing parameters to be passed and used inside It dinamically. As it uses a generic class algorithm (erb) It can be used in all plain text format files such as JSON, JavaScript, TypeScript, HTML, CSS, YAML, Markdown, SQL among others.
RubyGems:
gem install erbr
Gemfile:
gem "erbr", '~> 0.0.2'erbr works with a template and optional layout or arguments:
ERBR.render("template.html.erb", "layout.html.erb", :msg => "Binded Argument!")
# => <title>Layout Title</title>
# => <p>Template Content Binded With Layout</p>
# => <span>Binded Argument!</span>JSON files:
@post = {
:method => "POST",
:url => "https://localhost:3000",
:body => {
:key => "value"
}
}
ERBR.render("example.json.erb", nil, @post)
# => {
# => "method": POST,
# => "url": "https://localhost:3000",
# => "body": {
# => "key": "value"
# => }
# => }rspec spec/<format>_test_erbr.rb to run file specific behavior driven tests.
This project is under MIT license which grants you permission to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the software.