Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Precompilation of templates #17

Open
kesavkolla opened this issue Feb 5, 2013 · 10 comments
Open

Precompilation of templates #17

kesavkolla opened this issue Feb 5, 2013 · 10 comments

Comments

@kesavkolla
Copy link

ECT is an excellent template language. I like the way it support the client side templates using the middleware compilation. Is there any way to use the client side templates with pre compiled templates. I don't have a running node middleware on my hosting server. I want to precompile all the templates on my dev server and include the result js directly in my client app. Is there any way to achieve this?

Thanks
-Kesav

@baryshev
Copy link
Owner

baryshev commented Feb 5, 2013

This feature planned for next version.

@kesavkolla
Copy link
Author

Awesome. A batch compiler for ect templates and the output can be directly served to browser. It would be great if this can be integrated with Angular.js. Also cool thing would be to integrate with CodeKit so that it can auto compile the ect templates. I'd love to see this feature soon.

@kesavkolla kesavkolla reopened this Feb 6, 2013
@eliseumds
Copy link

Hey guys!

First of all, I would like to thank everyone, this is project is really impressive and helpful.

I've adapted the code so I can precompile the templates. If anyone is interest, please check my fork: https://github.com/eliseumds/ect

@aeischeid
Copy link

Previously we used eco with spine.js and hem. I would love to replace eco with ect in the spine.js docs, example apps and and hem and all that but precomplilation would be a requirement. I will keep an eye out for this feature landing. looks like you guys are doing good work. Keep going!

@baryshev
Copy link
Owner

First version of command-line compiler released just now (with v0.5.0). It have a basic functionality for now, but will be improved in future.

@mwcollins
Copy link

Hey All, What's the status of precompiling templates on the client side? I love ECT, but this is the only thing preventing me from integrating it. Currently the pre-complier outputs an anonymous function... how would one integrate the compiled output to be renderable by an ECT object instance?

I dug into the source a little bit... I was thinking maybe adding a method like:

renderer.register({ name:'foo', compiled:(function(){}) });

... this would add a record to the cache object internally

Then I would be able to:

renderer.render('foo',{});

I'll submit a patch if I end up writing it, but wanted to get your thoughts.

@baryshev
Copy link
Owner

If you need to serve all precompilied templates to client in one script/html (without ajax lazy load) you can use this syntax:

var renderer = new ECT({
    root : {
        foo: 'ectPrecompilledFuncitonHere',
        bar: 'ectPrecompilledFuncitonHere'
    }
});

After that you can use template foo and bar in your code.

@mwcollins
Copy link

Solid, thanks... is that the string source or is it the function reference?

@baryshev
Copy link
Owner

This is a string as it outputted by ect command line tool.

@brian-mann
Copy link

Unfortunately, I find this woefully inadequate. In my opinion ECT beats ECO all around, except for the fact that you're coupled to a server side implementation, and lazy loading the templates async.

My project has hundreds of templates - I doggedly control when those templates are loaded on the client. When a user visits a new page, I send down all the JS including the template code as one file. That way, the minimal code is loaded when the page first loads, but complete "page modules" are loaded lazily when they're needed.

It wouldn't make send to send the templates 1 file at a time on demand.

So that means that there needs to be a way to precompile them into a global namespace. Many templates already do this, ECO, EJS, Handlebars, Jade, etc. ECT not providing this is a real deal breaker.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants