Pure HTML + JavaScript client side templating

Posted by Dev er dev on Stack Overflow See other posts from Stack Overflow or by Dev er dev
Published on 2010-11-01T21:48:58Z Indexed on 2011/02/04 23:25 UTC
Read the original article Hit count: 291

Filed under:
|
|
|
|

I want to have achieve something similar to Java Tiles framework using only client side technologies (no server side includes).

I would like to have one page, eg layout.html which will contain layout definition. Content placeholder in that page would be empty #content div tag.

I would like to have different content injected on that page based on url. Something like layout.html?content=main or layout.html?content=edit will display page with content replaced with main.html or edit.html.

The goal is to avoid duplicating code, even for layout, and to compose pages without server-side templating.

What approach would you suggest?

EDIT: I don't need a full templating library, just a way to compose a pages, similar for what tiles do.

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about html