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 $engine = 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 'context' is expected to be set up.
package Some::Extended::JSAdapter;
use base 'EJS::Template::JSAdapter';
sub new {
my ($class) = @_;
my $context = Some::Underlying::JavaScript::Context->new();
return bless {context => $context}, $class;
}
context
Retrieves the underlying context 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")');