Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 package org.kohsuke.stapler.jelly.jruby;
 
 import  org.apache.commons.jelly.Script;
 
 import java.net.URL;

Per-ScriptingContainer portion of RubyTemplateLanguage.

One often needs to do some preparation work in every ScriptingContainer that it uses, such as loading gem. Instance of this captures that context.

Right now, we only use one ScriptingContainer, so this isn't serving any useful purpose, but this is in anticipation of the future expansion to handle multiple ScriptingContainers.

Author(s):
Kohsuke Kawaguchi
public class RubyTemplateContainer {
    
Subtype of JRubyJellyScript for this specific template language.
    private final RubyClass scriptClass;

    
Where we came from.
    public final RubyTemplateLanguage language;

    
This RubyTemplateContainer instance if scoped to this JRuby interpreter context.
    public final ScriptingContainer container;
    public RubyTemplateContainer(RubyClass scriptClassRubyTemplateLanguage languageScriptingContainer container) {
        this. = scriptClass;
        this. = language;
        this. = container;
    }
    public Script parseScript(URL paththrows IOException {
        try {
            String template = IOUtils.toString(path.openStream(), "UTF-8");
            return (Script) .callMethod("new"template);
        } catch (Exception e) {
            throw (IOExceptionnew IOException("Failed to parse "+path).initCause(e);
        }
    }
New to GrepCode? Check out our FAQ X