Search code examples
javascripthtmleclipsexhtmlhtml-generation

JavaScript library/framework to generate XHTML from parameters?


I have a rather complicated question :)

I want to send data in form of json from the server to the client.

There the data shall be used by javascript to generate XHTML from this data.

Now I am looking for a library/framework that helps me generate this XHTML from JSON.

For example a solution could be to have special XHTML "template" files that contain variables which are mapped by name to a javascript method and that method takes the JSON array and fills some parts of the XHTML with the variables in the JSON array.

Example Template File (Pseudocode):

filename: TemplateA.something

<html>
Hello my name is %VARIABLE1% !
</html>

And the frameworks generates me then a method like that (Pseudocode):

generateXHTMLfromTemplate(templatename, data);

and it would return XHTML.

For example i would then call it like that (Pseudocode):

container.html(generateXHTMLfromTemplate('TemplateA', '{"VARIABLE1" : "Earl"}'));

Something like that would be great, the best would be code-completion of these "template" files in eclipse ;)


Solution

  • Taken from the comment of the post:

    Something like this? github.com/janl/mustache.js – Blender yesterday

     

    Others to choose from: doT, Handlebars, Underscore. – Pointy yesterday