Disclaimer: This extension depends on a working JSR 223 environment as provided in Java 6 and newer. |
Parameter Name | Description |
---|---|
Input Parameters (set with the macro call) | |
"source-script" | Defines a shortcut for the request properties 'source-class' and 'script'. If this parameter is present inside the request parameters list, the system will effectively behave as if 'source-class' and 'script' where set separately. |
"script" | Sets the URL or local path to the script file to load and evaluate.
The specified file is resolved in exactly the same way as when using the parameter "source" (see Macro reference).
Notes:
|
Implementation "org.tinyjee.maven.dim.extensions.ScriptInvoker": ApiDoc | Source |
%{include|source-script=eval[js]:println("Hello World 1");}
%{include|source-content=$out|source-script=eval[js]:var out\="Hello World 2";}
Note: The use of inline scripts in combination with APT is limited as "{}|=" are special characters that require escaping. The script in the example above wouldn't work as expected without the backslash in front of "=".
1 2 | print( "Hello World - printed from JavaScript (output-is-HTML: " + globals.HTMLCapableSink + ")" ); var out = "Hello World - set to 'out' by JavaScript" ; |
%{include|source-script=samples/test-content-script.js}
%{include|source-content=$out|source-script=samples/test-content-script.js}
134 135 136 137 138 153 154 155 156 157 | < dependency > < groupId >org.codehaus.groovy</ groupId > < artifactId >groovy</ artifactId > < version >1.8.6</ version > </ dependency > < dependency > < groupId >org.tinyjee.dim</ groupId > < artifactId >doxia-include-macro</ artifactId > < version >${project.version}</ version > </ dependency > |
%{include|source-script=eval[groovy]:println "Hello World in Groovy (output-is-HTML: " + globals.HTMLCapableSink + ")";}
140 141 142 143 144 153 154 155 156 157 | < dependency > < groupId >org.jruby</ groupId > < artifactId >jruby</ artifactId > < version >1.6.6</ version > </ dependency > < dependency > < groupId >org.tinyjee.dim</ groupId > < artifactId >doxia-include-macro</ artifactId > < version >${project.version}</ version > </ dependency > |
%{include|source-script=eval[rb]:puts 'Hello World in Ruby (output-is-HTML: ' + $globals.isHTMLCapableSink().to_s + ')';}
146 147 148 149 150 153 154 155 156 157 | < dependency > < groupId >org.python</ groupId > < artifactId >jython-standalone</ artifactId > < version >2.5.2</ version > </ dependency > < dependency > < groupId >org.tinyjee.dim</ groupId > < artifactId >doxia-include-macro</ artifactId > < version >${project.version}</ version > </ dependency > |
%{include|source-script=eval[py]:print "Hello World in Python (output-is-HTML: " + str(globals.HTMLCapableSink) + ")"}