Mahiro Ando > EJS-Template-0.03 > EJS::Template::JSAdapter

Download:
EJS-Template-0.03.tar.gz

Dependencies

Annotate this POD

View/Report Bugs
Source  

NAME ^

EJS::Template::JSAdapter - JavaScript engine adapter for EJS::Template

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 $engine = EJS::Template::JSAdapter->create('JE');

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")');
syntax highlighting: