Skip to content

wnccys/erbr

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

106 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

erbr

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.

Installation

RubyGems:

gem install erbr

Gemfile:

gem "erbr", '~> 0.0.2'

Usage

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"
# =>   }
# => }

Testing

rspec spec/<format>_test_erbr.rb to run file specific behavior driven tests.

License

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.

About

gem that allows easily ERB template process with argument bound

Resources

License

Stars

Watchers

Forks

Contributors