use nodejs to render HTML pages with PURE

292 views
Skip to first unread message

Mic (BeeBole)

unread,
Dec 7, 2009, 5:47:16 PM12/7/09
to nodejs
Hi,
I'd like to port the templating engine PURE( http://github.com/pure/pure
) to nodejs... but quickly found there is no DOM on that side...
Then I thought that an XML parser over XHTML templates would do it
just fine, and could convert CSS selectors to Xpath.
Some modifications of pure.js would be needed too.
In the end it could be a good and same way to generate HTML on both
the client and the server with javascript.

I'll probably start with http://libxmljs.squishtech.com/.
Any advice or idea?

Thanks,
Mic

Roberto Saccon

unread,
Dec 7, 2009, 9:30:04 PM12/7/09
to nodejs
libxml does not lock you into XHTML, according to http://xmlsoft.org/
it also has a HTML 4 parser, which probably some would prefer over
XHTML.

And of course it would be great to have Pure on server and client !!

--
Roberto

On Dec 7, 7:47 pm, "Mic (BeeBole)" <tch...@gmail.com> wrote:
> Hi,
> I'd like to port the templating engine PURE(http://github.com/pure/pure
> ) to nodejs... but quickly found there is no DOM on that side...
> Then I thought that an XML parser over XHTML templates would do it
> just fine, and could convert CSS selectors to Xpath.
> Some modifications of pure.js would be needed too.
> In the end it could be a good and same way to generate HTML on both
> the client and the server with javascript.
>
> I'll probably start withhttp://libxmljs.squishtech.com/.

Bluebie

unread,
Dec 8, 2009, 12:17:48 AM12/8/09
to nodejs
Really, if you're in to performance (and many of us noders are), it
makes more sense to use an 'XML Builder' than a document object.

I made this little one, modelled vaguely on Markaby, a while ago..
http://github.com/Bluebie/Campy/blob/master/tago.js

I'd like to get rid of it's dependancy on mootools and make it in to a
nice simple tiny templating engine later. Likewise, there's no reason
you can't use tago in the browser too, inserting it's (html5 syntax)
results in to your document via innerHTML and gaining all the great
performance benefits which come along for free when creating elements
with innerHTML instead of the traditional more complex DOM
techniques. :)

On Dec 8, 1:30 pm, Roberto Saccon <rsac...@gmail.com> wrote:
> libxml does not lock you into XHTML, according tohttp://xmlsoft.org/

Elijah Insua

unread,
Dec 8, 2009, 2:17:57 AM12/8/09
to nod...@googlegroups.com
Nice idea!

I would really prefer this type of templating to the typical mixing of view logic with controller logic in a typical mvc type pardigm.

I went down the road to see how difficult it would be to integrate this into node properly and it seems like there are a couple roadblocks.

1) unless I am mistaken, libxmljs doesn't have a proper browser type DOM model which makes many of the libraries that pure is compatible with, fail.

2) I also went down the road of using env.js, but unfortunately it doesn't appear to be CommonJS module compatible. (I've made a post on their mailing list: http://groups.google.com/group/envjs/browse_thread/thread/2d5acefd5cb62e4d

At this point I envision utilizing envjs to provide a browser type wrapper for pure using libxmljs as a backend.  Not sure if I am completely off my rocker though!

-- Elijah


--

You received this message because you are subscribed to the Google Groups "nodejs" group.
To post to this group, send email to nod...@googlegroups.com.
To unsubscribe from this group, send email to nodejs+un...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/nodejs?hl=en.



Mic (BeeBole)

unread,
Dec 8, 2009, 5:51:01 AM12/8/09
to nodejs
On Dec 8, 8:17 am, Elijah Insua <tmp...@gmail.com> wrote:
> Nice idea!
>
> I would really prefer this type of templating to the typical mixing of view
> logic with controller logic in a typical mvc type pardigm.
>
> I went down the road to see how difficult it would be to integrate this into
> node properly and it seems like there are a couple roadblocks.
>
> 1) unless I am mistaken, libxmljs doesn't have a proper browser type DOM
> model which makes many of the libraries that pure is compatible with, fail.
>
> 2) I also went down the road of using env.js, but unfortunately it doesn't
> appear to be CommonJS module compatible. (I've made a post on their mailing
> list:http://groups.google.com/group/envjs/browse_thread/thread/2d5acefd5cb...)
>
> At this point I envision utilizing envjs to provide a browser type wrapper
> for pure using libxmljs as a backend.  Not sure if I am completely off my
> rocker though!

We could try something without DOM.
As a first shot, I would just take a clean HTML as a template,
some JSON data, mix them both to send the page to the browser.

PURE on the browser use DOM/CSS selectors to spot the node to
modify or repeat.
XPATH is very similar as CSS selectors to select nodes.
Though their syntax is different, but I found that
Joe Hewitt wrote a promising CSS Selector -> XPATH converter
http://www.joehewitt.com/blog/files/getElementsBySelector.js

>
> -- Elijah
>
>
>
> On Mon, Dec 7, 2009 at 5:47 PM, Mic (BeeBole) <tch...@gmail.com> wrote:
> > Hi,
> > I'd like to port the templating engine PURE(http://github.com/pure/pure
> > ) to nodejs... but quickly found there is no DOM on that side...
> > Then I thought that an XML parser over XHTML templates would do it
> > just fine, and could convert CSS selectors to Xpath.
> > Some modifications of pure.js would be needed too.
> > In the end it could be a good and same way to generate HTML on both
> > the client and the server with javascript.
>
> > I'll probably start withhttp://libxmljs.squishtech.com/.
> > Any advice or idea?
>
> > Thanks,
> > Mic
>
> > --
>
> > You received this message because you are subscribed to the Google Groups
> > "nodejs" group.
> > To post to this group, send email to nod...@googlegroups.com.
> > To unsubscribe from this group, send email to
> > nodejs+un...@googlegroups.com<nodejs%2Bunsu...@googlegroups.com>
> > .

Mic (BeeBole)

unread,
Dec 8, 2009, 5:57:26 AM12/8/09
to nodejs
I'm obsessed by performance too, if you look closely to the code.
PURE on the browser is a mix of easy DOM actions and innerHTML
injection for speed, and even in IE6 the rendering is fast.
Server side, not having to implement the DOM for templating would be a
nice quest.


On Dec 8, 6:17 am, Bluebie <b...@creativepony.com> wrote:
> Really, if you're in to performance (and many of us noders are), it
> makes more sense to use an 'XML Builder' than a document object.
>
> I made this little one, modelled vaguely on Markaby, a while ago..http://github.com/Bluebie/Campy/blob/master/tago.js

mvalente

unread,
Dec 8, 2009, 6:59:58 AM12/8/09
to nodejs


On Dec 7, 10:47 pm, "Mic (BeeBole)" <tch...@gmail.com> wrote:
> Hi,
> I'd like to port the templating engine PURE(http://github.com/pure/pure
> ) to nodejs... but quickly found there is no DOM on that side...

>
> I'll probably start withhttp://libxmljs.squishtech.com/.
> Any advice or idea?
>

Use a E4X DOM library (there are a few)

http://eligrey.com/blog/post/another-e4x-dom-library
http://eligrey.com/blog/post/e4x-dom-toolkit


Or use John Resig's env.js (you get jquery on the serverside)

http://github.com/thatcher/env-js

-- MV

Reply all
Reply to author
Forward
0 new messages