Sha256: 2e2d12dc083f5781570feeb7f2551c5c4a45bd7cdd7138f40e8809fd632de2ae

Contents?: true

Size: 653 Bytes

Versions: 108

Compression:

Stored size: 653 Bytes

Contents

# encoding: utf-8
require 'erb'

class EndERB
  class << self
    # for single template script using __END__ and DATA
    #
    # === Params
    #
    # * <tt>:hash</tt> - erb template variable hash
    #
    # === Example
    #
    #   def hoge
    #     hash = {
    #       hoge: '@hoge@',
    #       hige: '@hige@',
    #     }
    #     EndERB.apply(hash)
    #   end
    #
    #   puts hoge
    #
    #   __END__
    #   hoge=<%=hoge%>
    #   hige=<%=hige%>
    #
    # output
    #
    #   hoge=@hoge@
    #   hige=@hige@
    #
    def apply(hash)
      ERB.new(DATA.read).result(binding)
    end
  end
end

Version data entries

108 entries across 108 versions & 1 rubygems

Version Path
tbpgr_utils-0.0.151 lib/end_erb.rb
tbpgr_utils-0.0.150 lib/end_erb.rb
tbpgr_utils-0.0.149 lib/end_erb.rb
tbpgr_utils-0.0.148 lib/end_erb.rb
tbpgr_utils-0.0.147 lib/end_erb.rb
tbpgr_utils-0.0.146 lib/end_erb.rb
tbpgr_utils-0.0.145 lib/end_erb.rb
tbpgr_utils-0.0.144 lib/end_erb.rb
tbpgr_utils-0.0.143 lib/end_erb.rb
tbpgr_utils-0.0.142 lib/end_erb.rb
tbpgr_utils-0.0.141 lib/end_erb.rb
tbpgr_utils-0.0.140 lib/end_erb.rb
tbpgr_utils-0.0.139 lib/end_erb.rb
tbpgr_utils-0.0.138 lib/end_erb.rb
tbpgr_utils-0.0.137 lib/end_erb.rb
tbpgr_utils-0.0.136 lib/end_erb.rb
tbpgr_utils-0.0.135 lib/end_erb.rb
tbpgr_utils-0.0.134 lib/end_erb.rb
tbpgr_utils-0.0.133 lib/end_erb.rb
tbpgr_utils-0.0.132 lib/end_erb.rb