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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T01:37:29+00:00 2026-05-31T01:37:29+00:00

I have a JSON data object and a text/html javascript template written using the

  • 0

I have a JSON data object and a text/html javascript template written using the Moustache syntax. I’m using iCanHaz.js as a template parser.

My problem is that the first row in the data object doesn’t get displayed.

Here is my JS code:

 var data = jQuery.parseJSON('{"data":[{"title":"Title One"}, {"title":"Title Two"}]}');
 var html = ich.data_template(data);

And my Moustache template:

<script type="text/html" id="data_template">
    {{#data}}
       {{title}}<br />
    {{/data}}   
</script>

The above code outputs this as my rendered HTML:

<br />
Title Two<br />

As you can see “Title One” from the JSON object isn’t displayed.

Does anyone know why? I’m taking a guess it’s something to do with my JSON object not being structured correctly (arrays/objects).

Many thanks.

  • 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-31T01:37:30+00:00Added an answer on May 31, 2026 at 1:37 am

    Try setting the raw flag (2nd argument) to true.

    var data = jQuery.parseJSON('{"data":[{"title":"Title One"}, {"title":"Title Two"}]}');
    var html = ich.data_template(data, true); #Note the true.
    

    Also, why are you writing your JSON as a string and parsing it? You can do:

    var data = {"data": [{"title": "Title One"}, {"title": "Title Two"}]};
    var html = ich.data_template(data, true);
    

    Without the raw flag, it returns an array of node elements, and you will need to set a root level element for it to work.

    <script type="text/html" id="data_template">
        <div>
        {{#data}}
           {{title}}<br />
        {{/data}}   
        </div>
    </script>
    

    You can test this by running the following JavaScript in your console.

    ich.addTemplate('data_template', '{{#data}}{{title}}<br />{{/data}}');
    var data = {"data": [{"title": "Title One"}, {"title": "Title Two"}]};
    var html = ich.data_template(data, true);
    console.log(html);
    
    html = ich.data_template(data);
    
    console.log(html);
    
    ich.addTemplate('data_template_root', '<div>{{#data}}{{title}}<br />{{/data}}</div>');
    
    html = ich.data_template_root(data, true);
    console.log(html);
    
    html = ich.data_template_root(data);
    
    console.log(html);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an AJAX application that downloads a JSON object and uses the data
I have a problem accessing JSON data. I'm new to JSON and jquery so
I have a problem mapping a Json object recieved from the server into a
I've got a JSON value that has been converted from a JavaScript object using
I have an Action Method that returns a JSON-serialized object. The problem I'm having
i want to send a json string from a html webpage using javascript to
I have a Json object that I'm dumping into a jQuery template (tmpl). It
I have json data I've taken the first set of data and written it
If have a html form like <form method=POST action=http://.../file.php> <input type=text name=data id=data />
I have a JSON data like this: { hello: { first:firstvalue, second:secondvalue }, hello2:

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.