Skip to content
Simple ERB helper.
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
bin first commit Apr 10, 2016
lib
spec
.gitignore
.rspec
.travis.yml
Gemfile
LICENSE.txt
README.md
Rakefile
erbh.gemspec

README.md

ERBh

Simple ERB helper.

Build Status

Installation

Add this line to your application's Gemfile:

gem 'erbh'

And then execute:

$ bundle

Or install it yourself as:

$ gem install erbh

Usage

require 'erbh'
include ERBh

erbh('<%= @foo %>, <%= @bar %>', foo: 100, bar: 'zoo')
#=> "100, zoo"

erbh(<<-EOS, {foo: 1..3}, trim_mode: '%')
% @foo.each do |i|
<%= i %>
% end
EOS
#=> "1\n2\n3\n"

Define helper method

require 'erbh'
include ERBh

ERBh.define_method(:concat) {|a, b| a + b }

erbh('<%= concat @foo, @bar %>', foo: 'a', bar: 'b')
#=> "ab"

ERBh.define_method(:chomp) do |obj|
  if obj.nil?
    @_erbout.sub!(/,\s*\z/, '')
    ''
  else
    obj
  end
end

erbh('100, <%= chomp @foo %>', foo: nil)
#=> "100"
You can’t perform that action at this time.