Comments (7)
Having said that, my main attraction to CoffeeKup is using it as a "helper language" inside sam's Eco meaning
Eco does the templateing (streamable) and CK does view helping.
Rails
<%= content_tag 'div', class: 'some_class' ... %>
CoffeeKup
<%=ck -> div class: 'some_class' ... %>
from coffeekup.
I'm not really familiar with template streaming, but I don't think there should be a problem. No, we don't have to wait for the whole thing to return to get the output; as each function is executed it writes to a buffer. At this moment we might as well fire an event with the chunk, don't we?
I couldn't find any examples on streaming with Eco, nor support for it in its source code, but if you could point me in the right direction I'd be glad to study it and see what can be done in CoffeeKup.
from coffeekup.
Indeed you are right. That's awesome.
I don't think Eco does streaming at this point, I just thought that it's definitively possible, since Rails 3.1 (ERB) did it and ERB and Eco are similar.
from coffeekup.
OK! So, I think this could make it into 0.3.0 final. What do you think of this API (completely stolen from dustjs):
compiled_template(foo: 'bar', options: {stream: yes})
.on('data', (data) -> console.log data)
.on('end', -> console.log "c'est fini!")
.on('error', (err) -> console.log 'doh!')
from coffeekup.
Looks good, conforms to node de facto conventions. I wander if the buffer object can also be given as an option (optional).
compiled_template(foo: 'bar', options: {stream: yes, buffer: res})
and this way have the results sent directly to a http.ServerResponse
object, no additional plumbing. Ofc. res should respond to data, end and error.
from coffeekup.
How would that work exactly? We'd call res.write
and res.end
directly?
from coffeekup.
Yes that's what I was thinking. The interface for the buffer should be http://nodejs.org/docs/v0.5.1/api/streams.html#writable_Stream mainly the stream.write(...)
and stream.end(...)
.
If a buffer isn't explicitly given use something internally, so it works both on server and client.
from coffeekup.
Related Issues (20)
- DryKup, a fork of CoffeeCup HOT 1
- unused tags research
- Asynchronous document support
- using coffeekup with express
- How to include javascript body?
- How to access tag helpers from a different scope (e.g. inside a helper object instance)? HOT 1
- coffeekup cli not working with coffeescript 1.2 HOT 10
- svg tag support
- Lack of a unescape/safe helper when autoescape in on HOT 1
- Still alive? HOT 29
- Blocks / place holders in layouts HOT 2
- enabling and disabling button HOT 1
- CoffeeScript is going to make "yield" the reserved word HOT 3
- This project is dead? HOT 7
- you may be interested in this alternative: coffee-templates HOT 3
- Incorrect package.json HOT 4
- How To Refactor Right? HOT 1
- How to define custom tags?
- Is this project dead? HOT 26
- Moving to new github organisation for the longer suatainablity and maintenance of the project: New Org Coffeekup HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from coffeekup.