Templating library which generates HTML+JS for interfacing RESTfully?

A

Alec Taylor

Are there any templating libraries—e.g.: Jinja2, Django Template Engine, Mako &etc—which can be used to interface over REST, XMLRPC xor JSONRPC?

My use-cases follow:
1. Generate a website, e.g.: to run from example.com (currently every templating language does this out of the box)
2. Generate the JS, HTML and CSS to put into a mobile phone app (PhoneGap)
3. Generate JavaScript "widget" code for pasting onto your site (see footnote [1] for popular examples)

My current plan is to write the entire client using HTML, CSS (twitter-bootstrap responsive) and JavaScript—e.g.: with Backbone.js—allowing me to use that same client code for the website and PhoneGap clients. With that done, the widgets wouldn't be too difficult to extrapolate.

However, this seems like a really complex way of doing things, especially when taking into consideration checks requiring login, forced redirects and more fine grained RBAC.

Is there a templating language which can easily interface via REST (XML xorJSON), XMLRPC xor JSONRPC?

Thanks for all information and suggestions,

Alec Taylor

[1] | The example JavaScript widgets:
- DISQUS gives the following snippet:
`<script type="text/javascript" src="http://example.disqus.com/combinati...or=blue&default_tab=people&excerpt_length=200"></script><a href="http://disqus.com/">Powered byDisqus</a>`

- Facebook gives the following snippet:
`<div id="fb-root"></div><script>(function(d, s, id) {var js, fjs = d..getElementsByTagName(s)[0];if (d.getElementById(id)) return;js = d.createElement(s); js.id = id;js.src = "//connect.facebook.net/en_US/all.js#xfbml=1&appId=237216179703726";fjs.parentNode.insertBefore(js, fjs);}(document, 'script', 'facebook-jssdk'));</script>`
`<div class="fb-like" data-send="true" data-width="450" data-show-faces="true"></div>`

- Twitter gives the following snippet:
`<script charset="utf-8" src="http://widgets.twimg.com/j/2/widget.js"></script><script>new TWTR.Widget({version: 2,type: 'profile',rpp: 4,interval: 30000,width: 250,height: 300,theme: {shell: {background: '#333333',color: '#ffffff'},tweets: {background: '#000000',color: '#ffffff',links: '#4aed05'}},features: {scrollbar: false,loop: false,live: false,behavior: 'all'}}).render().setUser('twitter').start();</script>`
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

No members online now.

Forum statistics

Threads
473,767
Messages
2,569,570
Members
45,045
Latest member
DRCM

Latest Threads

Top