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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T03:12:38+00:00 2026-06-11T03:12:38+00:00

I have two objects that I want to render side by side. There is

  • 0

I have two objects that I want to render side by side. There is never a case where I will want to render more, or less than two. My model is setup like so:

{
  obj1: {...},
  obj2: {...}
}

Using mustache templates, I want to render each object using the same partial:

<div>
  <h1>Object 1</h1>
  {{>objPartial}}
</div>
<div>
  <h1>Object 2</h1>
  {{>objPartial}}
</div>

However, mustache doesn’t seem to support passing a context to the partial. Doing something like {{>objPartial obj1}} seems like it should be supported, but I can’t find any documentation on setting a context for a partial.

Is this sort of thing supported? If not, how can I accomplish the same effect without duplicating the partial (objPartial1 and objPartial2)?

  • 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-11T03:12:40+00:00Added an answer on June 11, 2026 at 3:12 am

    The syntax I think you are looking for is not {{>objPartial obj1}}, but rather it should be

    {{#obj1}}
    {{>objPartial}}
    {{/obj1}}
    

    The syntax for {{#}} isn’t only for arrays – for non array objects the object becomes part of the current scope.

    I’ve forked maxbeatty’s example and modified it to show this syntax:

    <script type="template/text" id="partial">
        <ul>
            {{#name}}
            <li>{{.}}</li>
            {{/name}}
        </ul>
    </script>
    
    <script type="template/text" id="main">
        <div>
            <h1>Stooges</h1>
            {{#object1}}
            {{>objPartial}}
            {{/object1}}
        </div>
        <div>
            <h1>Musketeers</h1>
            {{#object2}}
            {{>objPartial}}
            {{/object2}}
        </div>
    </script>​
    
    <script type="text/javascript">    
        var partial = $('#partial').html(),
            main = $('#main').html(),
            data = {
    
                object1: {
                    name: ["Curly", "Moe", "Larry"]},
                object2: {
                    name: ["Athos", "Porthos", "Aramis", "D'Artagnan"]}
    
            },
            html = Mustache.to_html(main,data, {
                "objPartial": partial
            });
        document.write(html);
    </script>
    

    Link to jsfiddle: http://jsfiddle.net/YW5zF/3/

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

Sidebar

Related Questions

I have two LinkedList objects that are always of the same size. I want
I have two objects that can be represented as an int, float, bool, or
I have a list of objects that have two int properties. The list is
Suppose that I have two objects with the same property name that I am
Let's say we have two objects. Furthermore, let's assume that they really have no
I have an interface and two objects implementing that interface, massively simplied; public interface
I have two threads, a producer thread that places objects into a generic List
I have Process objects that are monitored from two different views. A Windows.Forms.ListView (actually
I have a class that contains objects of two other classes. I need one
It is my understanding that two unequal objects can have the same hashcode. How

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.