8

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.

4 Answers 4

4

JavaScriptMVC has a view templating system that supports different engines, including a pure JavaScript based one called EJS.

You might also want to look into Mustache especially Mustache for JavaScript.

2

If you would like to use jQuery, there is a decent templating engine in development as well:

http://github.com/jquery/jquery-tmpl

http://api.jquery.com/jquery.tmpl/

1

Check this out:

http://layout.jquery-dev.net/

I thinks it's close to what you want.

I am looking at javascriptMVC at the same time.

In the forum they are talking about using jquery layout with it.

0

I don't know if it fit exactly to what you want to do, but using the GWT seems to be a good approach for rich client-side applications :

You write all your application in Java with the framework, and you compile for obtain HTML and JS files working stand-alone.

2
  • If you want to write web apps, learn javascript with jquery, it's probably easier and less frustrating in the long run, and definitely more powerful. Then you need to pick between either server side or client side view rendering. Mar 24, 2013 at 21:22
  • I prefer MooTools over JQuery, buts it is a matter of taste. GWT is just another tool, it's powerful and interesting to know its existence.
    – Pascal Qyy
    Mar 26, 2013 at 8:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.