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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T02:34:13+00:00 2026-06-18T02:34:13+00:00

Beginning at coding, JS, today I inject an HTML template several times into the

  • 0

Beginning at coding, JS, today I inject an HTML template several times into the HTML thanks to JS. However, I’am confused by the systematic need to minify the html indentation and fold all the dozen(s) of lines –div, h1, span, table, tr, td, tt– into a single var line. Minified html is both harder to ready and frequently need to be beautified back along the testing phase.

Also: is there a way to keep Beautified indented html in variable ?

Some syntaxe to have a valid version of:

var exampleTpl = "
      <div data-demo-html="true">
        <div data-role="collapsible-set" data-inset="true" data-theme="b" data-content-theme="d">
          <div data-role="collapsible" data-collapsed="false">
            <h4>Heading</h4>
            <ul data-role="listview" data-filter="false" data-inset="true">
              <li><a href="#">List item 1</a></li>
              <li><a href="#">List item 2</a></li>
              <li><a href="#">List item 3</a></li>
            </ul>
          </div>
"

Best thanks in advance,

  • 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-06-18T02:34:15+00:00Added an answer on June 18, 2026 at 2:34 am

    For templating purpose, you should have a look at the example on Handlebars.js homepage :

    Declare your template

    <script id="entry-template" type="text/x-handlebars-template">
      <div class="entry">
        <h1>{{title}}</h1>
        <div class="body">
          {{body}}
        </div>
      </div>
    </script>
    

    Compile a template in JavaScript

    var source   = $("#entry-template").html();
    var template = Handlebars.compile(source);
    

    Inflate the HTML

    var context = {title: "My New Post", body: "This is my first post!"}
    var html    = template(context);
    

    This will result in an instance of your template (value injected into your template) :

    <div class="entry">
      <h1>My New Post</h1>
      <div class="body">
        This is my first post!
      </div>
    </div>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

So, I am beginning the process of coding a PHP application website, which will
I'm beginning a computer vision project and I need to compute the horizontal and
We are in the beginning coding phase for project that we are using JPA
I am beginning work on coding a site and at the moment I am
I have used MS Money for several years now and due to my coding
since i'm at the beginning with Android coding i hesitated to post my question,
im just beginning coding with JSP. I just get confuse how to make the
Im beginning in my journey of learning WPF. After a few days of coding
Greetings all, This has confused me ever since I first started coding in C#.
I am busy coding a unit test for an AJAX file uploader. The beginning

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.