NAME
EJS::Template::JSAdapter - JavaScript engine adapter for EJS::Template
Variables
@SUPPORTED_ENGINES
Supported JavaScript engine classes
Methods
create
Instantiates a JavaScript engine adapter object.
my $adapter = EJS::Template::JSAdapter->create();
If no argument is passed, an engine is selected from the available ones.
An explicit engine can also be specified. E.g.
my $je_engine = EJS::Template::JSAdapter->create('JE');
my $v8_engine = EJS::Template::JSAdapter->create('JavaScript::V8');
new
Creates an adapter object.
This method should be overridden, and a property named 'engine' is expected to be set up.
package Some::Extended::JSAdapter;
use base 'EJS::Template::JSAdapter';
sub new {
my ($class) = @_;
my $engine = Some::Underlying::JavaScript::Engine->new();
return bless {engine => $engine}, $class;
}
engine
Retrieves the underlying engine object.
bind
Binds variable mapping to JavaScript objects.
This method should be overridden in a way that it can be invoked like this:
$engine->bind({
varname1 => $object1,
funcname2 => sub {...},
...
});
eval
Evaluates a JavaScript code.
This method should be overridden in a way that it can be invoked like this:
$engine->eval('print("ok\n")');