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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T21:51:26+00:00 2026-06-17T21:51:26+00:00

I am using Mustache for HTML templates and HoganJS as renderer. My problem is

  • 0

I am using Mustache for HTML templates and HoganJS as renderer. My problem is following:
I have table template (table, header, body), but also I have template for each TR element of TBODY. All I want is to reuse TR-template in the TABLE-template.

Whether it possible or not?

Sample code:

<!-- Row Template -->
<script type="text/html" id="table_row_template">
<tr>
    <td><input type="text" name="Name" class="item-name autocomplete-groups" value="{{name}}" /></td>
    <td><input type="text" name="count" class="item-count count" name="count" value="{{count}}" /></td>
</tr>
</script>

<!-- Table Template -->
<script type="text/html" id="section_table_template">
<table>
    <thead>
        <tr><th>Name</th><th>Count</th></tr>
    </thead>
    <tbody>
        <!--
            Here I want ot iterate over the collection
                and render template from '#table_row_template'
        -->
    </tbody>
</table>

</script>

<script type="text/javascript">
    var context = {
        collection: {
            {
                "item1": { "name": "item1", "count": "1" },
                "item2": { "name": "item2", "count": "12" },
                "item3": { "name": "item3", "count": "5" },
                "item4": { "name": "item4", "count": "32" },
                "item5": { "name": "item5", "count": "6" },
            },

         ..........
        }
    }

    var t = hogan.compile(document.getElementById('section_table_template').innerHTML);
    var rendered = t.render(context);
</script>
  • 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-17T21:51:27+00:00Added an answer on June 17, 2026 at 9:51 pm

    You’re looking for Mustache’s “partial” tag:

    <script type="text/html" id="section_table_template">
    <table>
        <thead>
            <tr><th>Name</th><th>Count</th></tr>
        </thead>
        <tbody>
            {{# collection }}
                {{> table_row }}
            {{/ collection }}
        </tbody>
    </table>
    </script>
    

    To get this to work with Hogan, you simply have to tell it where your partials are:

    <script>
    var t = hogan.compile(document.getElementById('section_table_template').innerHTML);
    var partials = {
        table_row: document.getElementById('table_row_template').innerHTML
    };
    var rendered = t.render(context, partials);
    </script>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm just getting started using Mustache and I have this rendering problem. I send
I have a JSON data object and a text/html javascript template written using the
I am using JSON and MUSTACHE, for templates in my new site. But I
I have a sinatra app that is mostly using erb for templates, but I
I am new to the mustache template library and have the following scenario. I
I'm using mustache to render stuff on the server, but also on the client.
Currently I'm using Mustache templates ( http://mustache.github.com/ ) both on the client and server-side,
I'm using mustache.js to render a template in javascript. I'd like to check if
CONTEXT: I have read as much Mustache documentation as possible but I cannot get
I am using icanhaz.js and mustache for loading templates, and I am loading mustache

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.