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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T17:05:21+00:00 2026-05-28T17:05:21+00:00

I am using this data here: http://pastie.org/3231052 – How can I display the key

  • 0

I am using this data here: http://pastie.org/3231052 – How can I display the key instead of the value using Mustache or Handlebars?

[{"interval":"2012-01-21",
  "advertiser":"Advertisers 1",
  "offer":"Life Insurance",
  "cost_type":"CPA",
  "revenue_type":"CPA",
  ... etc ...
}]
  • 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-28T17:05:22+00:00Added an answer on May 28, 2026 at 5:05 pm

    If you want to display key-value pairs, you can write a helper in Handlebars.

    Handlebars.registerHelper('eachkeys', function(context, options) {
      var fn = options.fn, inverse = options.inverse;
      var ret = "";
    
      var empty = true;
      for (key in context) { empty = false; break; }
    
      if (!empty) {
        for (key in context) {
            ret = ret + fn({ 'key': key, 'value': context[key]});
        }
      } else {
        ret = inverse(this);
      }
      return ret;
    });
    
    $(function() {
        var data = {"interval":"2012-01-21",
          "advertiser":"Advertisers 1",
          "offer":"Life Insurance",
          "cost_type":"CPA",
          "revenue_type":"CPA"};
                    
        var source   = $("#template").html();
        var template = Handlebars.compile(source);
        $('#content').html(template({'data': data}));
    });
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/handlebars.js/1.0.0.beta2/handlebars.min.js"></script>
    <script id="template" type="text/x-handlebars-template">
        {{#eachkeys data}}
        <li>{{this.key}} - {{this.value}}</li>
        {{/eachkeys}}
    </script>
    <div id="content">
    </div>

    EDIT

    Seems like this isn’t quite what you want, but it’s possible to come up with a helper that will do the trick.

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

Sidebar

Related Questions

I have an HBITMAP containing alpha channel data. I can successfully render this using
I am using the exact code seen here: http://gazpo.com/downloads/tutorials/html5/contentEditable/ As you can see, when
Kind of following this tutorial here: http://mobile.tutsplus.com/tutorials/iphone/iphone-core-data/ I use the fetch records method in
I'm trying to change the ID of an element here: http://moemonty.com/chirp/CHIRP-JSON-test.html By using this
I have a dict object. I dumped the data using this: for alldata in
I've been using this nifty LINQ to SQL tool for a data access layer
I am accessing this data from a web server using NSURL, what I am
i m using this article http://blogs.msdn.com/delay/archive/2009/09/23/if-it-walks-like-a-duck-and-talks-like-a-duck-it-must-be-a-treegrid-a-simple-xaml-only-treegrid-ui-for-wpf.aspx to have hierarchical data... i am having treeview
I have a data object that is deep-cloned using a binary serialization. This data
I have this big data-entry sort of page, a table kind of layout using

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.