Pithy.js - An internal DSL for generating HTML in JavaScript
github.com
github.com
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.
[1] https://github.com/crabasa/seattlehacks/blob/gh-pages/calend...
Templates are useful, so are tag generation code snippets. Both go in my toolbox just fine.
/sarcasm
My point still stands, no matter what you think you read in my post, different tools for different jobs is OK, there is no "silver bullet" (or magic-hammer or whatever).
1) cross domain AJAX via CORS
2) Injecting HTML strings constructed in JS
For small amounts of HTML, I'd much rather go with option #2.
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.
I haven't used this yet, so bear that in mind, but to me this seems to be something that is more expressive than html (I meant String) concatenation. That leads, in my experience, to better maintainability and thus less worries in the future.
Whether this impacts JS performance enough to be a problem, I don't know and don't have the time to test right now.
Edit: words are hard... I accidentally a few of them.
1) cross domain AJAX via CORS
2) Injecting HTML strings constructed in JS
For small amounts of HTML, I'd much rather go with option #2.
ps. Its unfortunately very common for developers to have little or no server side access to the applications they're building.
If you can easily avoid a call to the server, it might be a good idea.
You've described server-side libraries. Client-side do the exact same thing in JS on the client.
With every HTML injection, I'd have to cycle through all relavant nodes, sorting out the ones that have already been binded, and then apply the relevant bindings. With a dynamic app that injects a lot of small HTML parts, this could be quite painful.
I can see how this can be helpful cleaning up e.g. common string concatenation snippets in code bases.