Kerb
ERB rendering can be a like driving over a rocky road. This library aims to solve this problem by offering an easy interface to render ERB from a string, from a file or towards a file. Get off the road and onto the kerb!
Installation
Add this line to your application's Gemfile:
gem 'kerb'
And then execute:
$ bundle
Or install it yourself as:
$ gem install kerb
Usage
Render a string
erb = 'my <%= @foo %> <%= @bar %>'
vars = {
foo: 'lovely',
bar: 'garden'
}
Kerb.render(erb, vars) #=> "my lovely garden"
Render to a file
erb = 'my <%= @foo %> <%= @bar %>'
vars = {
foo: 'lovely',
bar: 'garden'
}
file = 'path_to_file'
Kerb.render_to_file(erb, vars, file)
File.read(file) #=> "my lovely garden"
Contributing
Bug reports and pull requests are welcome on GitHub at https://github.com/sebastiaandegeus/kerb. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.
License
Copyright (c) 2016 Sebastiaan de Geus
The gem is available as open source under the terms of the MIT License.