4 ms·
JSON Template
- mpk 18y agoCool project. Much like Ruby, Python seems easy to match to JSON. Also, check out JsonML : http://jsonml.org/ http://jsonml.org/ . The focus lies more on the client side templating (where it's all JS anyway), but it has additional goodies like XML-to-JsonML XSLT transformation.
- lecha 18y agoSeparating presentation and data in applications an accepted design practice, but somehow it is not as common in-browser apps as it is on the server side. Here's an architecture of a dynamic web app that works well for me: - an app server exposes JSON and no HTML. (eg django or rails) - html/css/js is completely static (eg. on S3/CDN) and defines UI as a set of HTML templates. - once html/js is loaded in the browser, the browser makes an AJAX call to the server to get the JSON data - in-browser JS expands a template, the data is rendered out In this architecture, http://code.google.com/p/google-jstemplate/ http://code.google.com/p/google-jstemplate/ is key. Check it out.
- tlrobinson 18y agoWe're also starting to see more server-side JavaScript, which would make these thing even more useful.
- gcv 18y agoClean, but what are you supposed to do with user agents which do not support JavaScript? Server-side templates still let you customize the page in that case.
- lecha 18y agoRight, in this case client-side templating just moves to the server. When JS processing isn't available on the client side, this same stack is moved to the server side. This way the same logical separation between UI and data is maintained.
- andreyf 18y agoEvery successful website needs an API I, for one, am really looking forward to news.YC's API...
- uggedal 18y agoIt has an API. It's called Hpricot/BeautifulSoup and duct tape.
- carlosrr 18y agoI made a light version of haml for javascript called baconl. It doesn't support embedded code, but I have found that it is not needed when used with most javascript frameworks. http://code.cohitre.com/baconl/ http://code.cohitre.com/baconl/
- stevoski 18y agoThis reminds me of Microsoft's first attempt at web scripting, before ASP. Can't remember what it was called, but for each final HTML page it had a template file and a database query file. It turned out to be just too hard to do anything useful with it.
- tjpick 18y ago> Motivation... they reinvent things like for loops, if statements, and expressions poorly and how is incredibly ugly looping and conditional syntax the solution? > {.repeated section @}, {.or}
- nostrademons 18y agoWhy does it need separate constructs for {.section} and {.repeated section}? You could take the absence of a key to signify "hide this section", its presence to signify "show it once, with these values", and its presence as an array to signifiy "show it multiple times, one per element". That's the way google-ctemplate works, and it seems to work quite well. (BTW, I had no idea Google's templating library was an open-source project. Kinda fun to see that the stuff I work with daily isn't a proprietary walled garden after all. And some trivia for those who don't routinely Google project owners: it's written and maintained by Google's employee #1.)