juliangruber / koa-dom

Dom templating for koa.
11 stars 1 forks source link

status of koa-dom #1

Closed jeromew closed 10 years ago

jeromew commented 10 years ago

This module seems very interesting for using koa with streams.

It is hard to know if the hyperstream dependency if fully functional (what kind of security do you have when you start to stream utf-8 user edited content (?)). I'll have to try and understand that a bit better.

I would be interested to know if you are satisfied/ really using koa-dom because the overal concept of a stream-replacer is very interesting in the context of koa.

I tried to make "react" work on the server side to make a diffing push but react seems difficult to implement realistically on the server side & it may hard to extract the diffs + even for simple html I got things out like :

<div data-reactid=".r[5i3v9]"><span data-reactid=".r[5i3v9].[0]">Hello </span>
<span data-reactid=".r[5i3v9].[1]">World</span></div>
 ... not really something I would send on the network

I also found https://github.com/dodo/node-dynamictemplate but like react your must keep a full dom virtual image before sending your modification events. It might be easier though to extract the diffs : https://github.com/dodo/node-dynamictemplate

An Adapter is little modules that listens for these events and act accordingly
on its domain. This means if you use dt-jquery or dt-dom it will create a dom element.
in the case of dt-stream it will create a nodejs stream instance that emits html strings as data.

Thanks for your feedback on this

juliangruber commented 10 years ago

It is hard to know if the hyperstream dependency if fully functional (what kind of security do you have when you start to stream utf-8 user edited content (?)). I'll have to try and understand that a bit better.

Make sure user submitted content is sanitized / escaped before you put inside your datastore.

I would be interested to know if you are satisfied/ really using koa-dom because the overal concept of a stream-replacer is very interesting in the context of koa.

Currently I'm mostly using co-render for templates as use cases where streaming templating are of good use are rather rare: Only if your page is big and uncached the streaming gives real gains.

Regarding react, I have no idea how it works and this seems more like a templating language independent question, so you'd be better off posting that on react's issue list.