jstransformers / jstransformer-function

Function support for JSTransformers.
http://npm.im/jstransformer-function
MIT License
0 stars 0 forks source link

Add compileClient #2

Closed ForbesLindesay closed 8 years ago

ForbesLindesay commented 9 years ago

This needs testing, I haven't actually tried running this.

RobLoach commented 9 years ago

There aren't much docs for .compileClient, so I'm not quite sure what it accomplishes. Does it mimic that of Jade's http://jade-lang.com/api/ ? The .compile() implementation, returned as a string that can be used on the client side?

Know if test-transformer has support for it? For everything client-side, I've been using Browserify.

ForbesLindesay commented 9 years ago

It's intended to allow us to write a browserify transform that replaces code like:

var fnt = require('jstransformer')(require('jstransformer-function'));
var fn = fnt.compile('return "Hello" + this.name');

with:

var fn = function (locals) { return function () { return "Hello" + this.name }.call(this) };

Unfortunately, the output format isn't very standardised yet, so we need to think about what this should be. A few questions to answer:

We should answer those questions and then build tests for them. We don't really need to actually test in real browsers. compileClient really just means, compileToJavaScriptString, but client is a bit snappier and is the only real use case I can think of.