mde / ejs

Embedded JavaScript templates -- http://ejs.co
Apache License 2.0
7.72k stars 843 forks source link

v8js #103

Closed jaroslawziolkowski closed 8 years ago

jaroslawziolkowski commented 9 years ago

Hello, how can I use it with v8js in PHP.

I have installed 2.3.3 version by npm on server

$js = <<< EOT
        var template = ejs.render("",{},{});

EOT;

            try{
                $v8js->executeString($js,'ident.js');
            }catch (V8JsException $e){
                var_dump($e);
            }

result is

Fatal error: Uncaught exception 'V8JsException' with message 'ident.js:1: ReferenceError: ejs is not defined'
TimothyGu commented 9 years ago

I'm not sure how V8JS works, but you at least need to require ejs somehow. Try var ejs = require('ejs') before you use the compile function.

jaroslawziolkowski commented 9 years ago

@TimothyGu I see

require is not defined

when I use this construction

TimothyGu commented 8 years ago

EJS was written for Node.js. You need to get in touch with V8js on how to use CommonJS modules.