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.

Pithy.js - An internal DSL for generating HTML in JavaScript

52 pointsby sdogruyolabout 12 years ago

12 comments

crabasaabout 12 years ago
It is worth noting that the OP is calling this tool pithy (terse, meaningful). In an application I'm working on [1] I have several lines of jQuery and string concatenation to build some simple content.<p>It's probably overkill to use a full-blown client-side templating engine, but my current code leaves much to be desired. I think pithy.js might be a great fit.<p>[1] <a href="https://github.com/crabasa/seattlehacks/blob/gh-pages/calendar.html" rel="nofollow">https://github.com/crabasa/seattlehacks/blob/gh-pages/calend...</a>
sophaclesabout 12 years ago
This is almost identical in operation to laconic <a href="https://github.com/joestelmach/laconic" rel="nofollow">https://github.com/joestelmach/laconic</a> what advantages does this have?
atiripabout 12 years ago
Nope. Avoid. Switch to templates at the moment you think you need this kind of a solution. Use for example super comoact <a href="http://archan937.github.com/templayed.js/" rel="nofollow">http://archan937.github.com/templayed.js/</a> Compared to almost full blown mustache implementation, pithy.js, surprise, is a bloat. Sorry of being harsh, as a positive note, the code itself, in abstract way is my liking. Very good. May even steal some snippets.
评论 #5488354 未加载
jimmytucsonabout 12 years ago
See also:<p><a href="http://github.com/markgandolfo/el.js" rel="nofollow">http://github.com/markgandolfo/el.js</a><p><a href="http://joestelmach.github.com/laconic/" rel="nofollow">http://joestelmach.github.com/laconic/</a><p><a href="http://domo-js.com/" rel="nofollow">http://domo-js.com/</a>
muxxaabout 12 years ago
Almost identical functionality appears as part of MochiKit, and I've found it very useful for quick and clean DOM creation:<p><a href="http://mochi.github.com/mochikit/doc/html/MochiKit/DOM.html" rel="nofollow">http://mochi.github.com/mochikit/doc/html/MochiKit/DOM.html</a>
dropdownmenuabout 12 years ago
Pretty cool project, but I feel kind of dirty having js and html being so tightly bound to each other. Do you have a specific use case where pithy would perform faster or be more cleanly implemented than standard templates?
评论 #5486588 未加载
评论 #5487024 未加载
Zelphyrabout 12 years ago
Why is everyone so afraid of HTML that they insist on starting projects like this? I've seen them come and go for 15+ years now and they're never useful. Even less so in the case of using JS to generate HTML because that makes the browser actually work harder.<p>This isn't a knock against OP or the project creator (if they're not one and the same) because projects like these can be useful exercises. But I would never use something like this in production and I would hope nobody else would either.
评论 #5487350 未加载
评论 #5487046 未加载
spyderabout 12 years ago
Also there is DOMBuilder <a href="https://github.com/insin/DOMBuilder" rel="nofollow">https://github.com/insin/DOMBuilder</a> which has separate modes for using HTML mock elements on (node.js) server-side or DOM elements in browsers. The mock elements are implementing only a very small set of the DOM functions, but if you extend it a little then it can be useful to share Backbone-like views between server and client.
grimtriggerabout 12 years ago
Awesome! Would be useful if there were callbacks for binding events after the node has been created.
评论 #5486482 未加载
评论 #5486865 未加载
ajitkabout 12 years ago
I prefer <a href="https://github.com/jed/domo" rel="nofollow">https://github.com/jed/domo</a> to create DOM elements in browser. Its output is a real DOM element whereas in pithy.js, its string.
评论 #5487357 未加载
Bjoernabout 12 years ago
This is quite interesting, thank you for open sourcing it.<p>I can see how this can be helpful cleaning up e.g. common string concatenation snippets in code bases.
gohwellabout 12 years ago
Pardon my ignorance... What is a DSL?
评论 #5488287 未加载