Skip to content

Instantly share code, notes, and snippets.

@cowboyd
Created March 25, 2011 02:22
Show Gist options
  • Save cowboyd/886256 to your computer and use it in GitHub Desktop.
Save cowboyd/886256 to your computer and use it in GitHub Desktop.
package ruby;
import org.jruby.RubyClass;
import org.jruby.RubyObject;
import org.jruby.embed.ScriptingContainer;
public class ERBSpike {
public static void main(String[] args) {
ScriptingContainer jruby = new ScriptingContainer();
jruby.runScriptlet("require 'erb'");
RubyClass erb = (RubyClass) jruby.runScriptlet("ERB");
RubyObject template = (RubyObject) jruby.callMethod(erb, "new", "Hello <%= @name %>");
String result = jruby.callMethod(template, "result");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment