ERB Sandbox v0.1.2

ERB Sandbox allows you to encapsulate your program from ERB.

Problem

When you use ERB.new(code).result "code" can use all parts of your program. For example:

class ImportantClass
   def self.nuke_world
      launch_rockets
   end
end

ERB.new('<% ImportantClass.nuke_world %>').result

World is being bombed!!! It makes me cry:(

Solution

So, I just wanna render some template with some predefined variables.

With erb_sandbox gem I can do:

class ImportantClass
   def self.nuke_world
      launch_rockets
   end
end

begin
  ErbSandbox.render('<% ImportantClass.nuke_world %>')
  laugh # it will never happen
rescue
  # HA-HA-HA ImportantClass is undefined!
end

Usage

It's pretty simple:

ErbSandbox.render 'Hello, <%=user_name%>', user_name: 'dude' # => 'Hello, dude'

Copyright

Copyright (c) 2015 Dmitriy Non. See LICENSE.txt