Hosted by Three Crickets

Scalable Alternative to JSR-223

Scripturian logo: kitten in shawl


Go back to the manual's table of contents

Part 6: Extending Scripturian

Scriptlet Plugins

You can enhance the scriptlet parsing environment via scriptlet plugins. As an example, let's install a "shout" tag that prints out the content of the tag with an exclamation point at the end:

class MyPlugin implements ScriptletPlugin {
	public String getScriptlet( String code, LanguageAdapter languageAdapter, String content ) {
		if( code.equals( "!!!" ) ) {
			return "print('" + content.trim().replace( "'", "\\'" ) + "' + '!')";
		throw new RuntimeException( "We do not support tag: " + code );

parsingContext.getScriptletPlugins().put( "!!!", new MyPlugin() );
We would then be able to use the new "shout" scriptlet tag like so:

This is going to be <%!!! shouted out >

Our "shout" tag in this example is not very useful, but of course you can do anything with the content. You are not required to return any code: the tag can be used to perform special operations during the parsing phase of the exectuable. Further points to note:

Supporting Other Language Engines

To add a new language to Scripturian, you will first need to create a language adapter for it. If the language supports the Java scripting standard (JSR-223), then you can use the JSR-223 adapter. However, our experience has shown that adherence to the Java scripting standard is inconsistent, and that it's often better to create your own adapter.

Go back to the manual's table of contents