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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T17:38:09+00:00 2026-05-25T17:38:09+00:00

Should client-side templates like the following (using underscore’s templating engine): <p class=foo><%= bar %></p>

  • 0

Should client-side templates like the following (using underscore’s templating engine):

<p class="foo"><%= bar %></p>

be placed in an separate HTML file, or a separate JavaScript file? I know it could work both ways.

For example, a JavaScript file could just contain a list of string variables like so:

var cute = '<p class="the"><%= unicorn %></p>';
var fb   = '<p class="new-design"><%= sucks %></p>';

But I have also seen the following:

<script type="text/template" id="omg-template">
  <span id="swag-name"><%= name %></span>
</script>

Just from a Separation of Concerns standpoint, where does the template storage belong?

  • 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-25T17:38:10+00:00Added an answer on May 25, 2026 at 5:38 pm

    I usually will use an asset management system that concatenate and minify javascripts and css, and translate client side template files into JS strings hanging off a global var. This sort of thing depends on your platform, but in the rails world you want to look at jammit or sprockets (which is now part of rails)

    If I don’t have decent asset management, I will usually end up using the script tag method, with the templates split out into partials on the server, and included into the bottom of the page. It is sort of a pain to work with, but IMO anything more then your simple example string templates really shouldn’t exist inline in your javascript file.

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

Sidebar

Related Questions

Should a browser based Feed Reader always use something on the client side, like
Building a client-side swing application what should be notified on a bus (application-wide message
I should clarify that I am looking for a client-side solution. Alternatively, is there
I'm confused on how I should return errors to a client using SOAP. I
Update I want to avoid compiling the templates client-side, and have them compile during
I am developing some client side Javascript that is using some JSON web services
I've recently been using Steve Sanderson's knockout js library http://knockoutjs.com/ in my client side
Since I'm developing a multiplayer card game for Facebook using Flex as client side
I'd like to send a JSON rpc to a remote web-server. The client-side of
Should I provide these things by default or only on client request (if they

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.