TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Simplify templating with node.js, jsdom 0.2.0 and weld

47 pointsby indexzeroover 14 years ago

6 comments

simonwover 14 years ago
DOM-based templating is a horrible idea, at least for the majority of projects I've ever worked on.<p>The whole point of using templates is to separate your presentation logic from the rest of your application - ideally, you can hand the templates over to a client-side developer/designer and they can re-jiggle everything on their own.<p>If your templating code works by performing manipulations against a DOM, even minor changes to your page structure require to to completely rewrite both the templates and the code that manipulates them. I'd much rather leave my "view" code alone and just alter the template.
评论 #2238837 未加载
评论 #2238582 未加载
评论 #2238603 未加载
评论 #2238594 未加载
评论 #2238804 未加载
georgecalmover 14 years ago
The fact that it's all std-based, and back/front-end rendered is beautiful, but what seriously bothers me is how much weld.js is tied to jQuery.<p>The README states "Use with whatever library you want, jQuery for example". Let's analyze that for a second.<p>Weld.js uses the following jQuery methods: - Sizzle selector ($) - first() - is() - val() - attr() - text() - map() - extend() - clone() - data() - remove()<p>These methods are used throughout the 249 lines of code.<p>This makes weld.js completely dependent on jQuery. Thus, you <i>can't</i> just use whatever library you want. And that would be allright, if the README would say that; but it didn't, and so it isn't.
评论 #2240276 未加载
soljin2000over 14 years ago
<a href="http://www.yuiblog.com/blog/2010/09/29/video-glass-node/" rel="nofollow">http://www.yuiblog.com/blog/2010/09/29/video-glass-node/</a> This video from David Glass shows why this can be very powerful when code on the front end and the backend. It's pretty straight forward. Check for content. If not generate content. Attach behavior (skipped on the server). render out put (the branch between the server and the front end).<p>There is an example using express and all kinds of cool business.
gcvover 14 years ago
The Enlive system (for Clojure, see <a href="https://github.com/cgrand/enlive" rel="nofollow">https://github.com/cgrand/enlive</a>) does something very similar.
评论 #2238885 未加载
评论 #2239188 未加载
jlsyncover 14 years ago
My attempt at the same idea using jquery: <a href="https://github.com/jlsync/jlt/blob/master/jlt.js" rel="nofollow">https://github.com/jlsync/jlt/blob/master/jlt.js</a><p>Anyone have any pointers to other/better similar solutions?
meikericover 14 years ago
Good stuff!