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 1073105
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T20:56:50+00:00 2026-05-16T20:56:50+00:00

Has anyone implemented John Resig’s micro-templating in production code? In particular I’d like to

  • 0

Has anyone implemented John Resig’s micro-templating in production code? In particular I’d like to know if embedding the templates with <script type="text/html"> has caused any problems.

A bit more information: here’s the sort of thing I’m worried about:

  • My users are mostly in corporate environments – could an unusual proxy server mangle or strip out the templates
  • The embedded templates seem to fail W3C validation. What if, for instance, the next version of IE decides it doesn’t like them?
  • 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-16T20:56:50+00:00Added an answer on May 16, 2026 at 8:56 pm

    I abandoned inlining templates through scripttags as my view layer would create redundant duplicate script templates. Instead I placed the templates back into the JavaScript as string:

    var tpl = ''.concat(
        '<div class="person">',
            '<span class="name">${name}</span>',
            '<span class="lastname">${lastName}</span>',
        '</div>'
    );
    

    I used the string concat trick so I could make the template string readable. There are variations to the trick like an array join or simply additive concatenation. In any case, inline script templates works and works well, but in a php/jsp/asp view layer, chances are you will create redundant duplicate script templates unless you do even more work to avoid it.

    Furthermore, these templates become rather complex the more logic you have to add to them, so I looked further and found mustache.js which imo. is far superior and keeps the logic (conditions and dynamic variable definitions) in the JavaScript scope.

    Another option would be to retreive template strings through ajax, in which case you can put each template inside it’s own file and simply grant it a .tpl extention. The only thing you have to worry about is the http request roundtrip, which should not take too long for small .tpl files and is imo. insignificant enough.

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

Sidebar

Related Questions

Has anyone implemented the Enterprise Library VAB along wtih Code Contracts in .NET 4.0?
Anyone has implemented like the below carousel ? Note: The list of items should
Has anyone implemented facebook Like on iPhone/iPad? I've done general Facebook Connect implementation before,
Are there any open-source compression/decomp libraries available for Ruby? Has anyone implemented LZW? Or,
Has anyone ever used the hidden class PackageParser in Android source code with java
Has anyone implemented the DIRAC2 library from http://www.dspdimension.com/technology-licensing/dirac2-iphone/ for real time pitch correction on
Silverlight 2 is missing the unload event for a UserControl. Has anyone implemented a
Has anyone already implemented a circular buffer in JavaScript? How would you do that
Has anyone implemented their own AdminSite? How easy/hard was the basic implementation? I'm in
Possible Duplicate: android steganography Has anyone implemented steganography on android? Can anyone post sample

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.