Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 737951
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T07:46:51+00:00 2026-05-14T07:46:51+00:00

Templates are a pretty healthy business in established programming languages, but are there any

  • 0

Templates are a pretty healthy business in established programming languages, but are there any good ones that can be processed in JavaScript?

By “template” I mean a document that accepts a data object as input, inserts the data into some kind of serialized markup language, and outputs the markup. Well-known examples are JSP, the original PHP, XSLT.

By “good” I mean that it’s declarative and easy for an HTML author to write, that it’s robust, and that it’s supported in other languages too. Something better than the options I know about. Some examples of “not good”:


String math:

element.innerHTML = "<p>Name: " + data.name
    + "</p><p>Email: " + data.email + "</p>";

clearly too unwieldy, HTML structure not apparent.


XSLT:

<p><xsl:text>Name: </xsl:text><xsl:value-of select="//data/name"></p>
<p><xsl:text>Email: </xsl:text><xsl:value-of select="//data/email"></p>

// Structurally this works well, but let’s face it, XSLT confuses HTML developers.


Trimpath:

<p>Name: ${data.name}</p><p>Email: ${data.email}</p>

// This is nice, but the processor is only supported in JavaScript, and the language is sort of primitive (http://code.google.com/p/trimpath/wiki/JavaScriptTemplateSyntax).


I’d love to see a subset of JSP or ASP or PHP ported to the browser, but I haven’t found that.

What are people using these days in JavaScript for their templating?

Addendum 1 (2008)

After a few months there have been plenty of workable template languages posted here, but most of them aren’t usable in any other language. Most of these templates couldn’t be used outside a JavaScript engine.

The exception is Microsoft’s — you can process the same ASP either in the browser or in any other ASP engine. That has its own set of portability problems, since you’re bound to Microsoft systems. I marked that as the answer, but am still interested in more portable solutions.

Addendum 2 (2020)

Dusting off this old question, it’s ten years later, and Mustache is widely supported in dozens of languages. It is now the current answer, in case anyone is still reading this.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T07:46:51+00:00Added an answer on May 14, 2026 at 7:46 am

    You might want to check out Mustache – it’s really portable and simple template language with javascript support among other languages.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

g++ sometimes produces pretty convoluted outputs. Specially when dealing with templates. Is there any
Same for CMap, CList, and pretty much everything that uses templates (I guess). I
I want to modify this code which works pretty good but (or I don't
I'm pretty sure the answer is you can't use templates, you have to use
I'm reading Vandevoorde and Josuttis's C++ Templates The Complete Guide (which seems pretty good,
I'm getting pretty good at using xcode and objective c, but only from the
I'm trying to render a pretty simple data structure using RABL, but I can't
I'm using this pretty handy JavaScript template library: https://github.com/blueimp/JavaScript-Templates . I can create elements
Ok, so I have an XML file that pretty much looks like this: <Templates>
Underscore templates seem pretty simple, but I'm working on my first attempt and am

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.