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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T10:10:02+00:00 2026-05-27T10:10:02+00:00

I have a simple mustache template setup that takes an object player and creates

  • 0

I have a simple mustache template setup that takes an object player and creates a list element. What’s the best way to perform a javascript method on a variable in mustache? Here’s some sample code:

var playerTemplate = '<li><span class="player-position">{{ position }}</span><span class="player-name">{{ first_name }} {{ last_name }}</span></li>';
var playerRow = Mustache.to_html(playerTemplate, player);
$('ul#players-list').append(playerRow);

what i’d like to do is something like:

{{ position.toUpperCase() }}

I’d rather not change the object itself, because i may want {{ position }} to not be upper case in other situations. Any tips on the cleanest smartest way to do this?

Thanks much.

  • 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-27T10:10:02+00:00Added an answer on May 27, 2026 at 10:10 am

    Mustache is intentionally very simple (“Logic-less templates”) so there’s not a lot you can do. One option is to add a positionUC property:

    player.positionUC = player.position.toUpperCase();
    

    and then in the template:

    {{positionUC}}
    

    You can also add functions:

    // Note that render(text) will be HTML though...
    player.uc = function(text, render) { return render(text).toUpperCase() };
    

    and then in the template:

    {{#uc}}{{position}}{{/uc}}
    

    Perhaps you could switch to Handlebars and add a helper to uppercase things.

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

Sidebar

Related Questions

I have simple win service, that executes few tasks periodically. How should I pass
I have simple issue setting a two-way databinding of a checkbox in Silverlight 3.0.
I have simple WinForms application where modifying Windows Registry. The problem is that in
i have simple QStandardItemModel that holds the date to show in QTreeview when i
I have simple aspx page that has a form and a input field in
I have simple AJAX function that uses jQuery to return an array of 300
I have simple link list and when you hover over it it appends a
I have simple test project which creates a frame and adds one JTextPane to
I have simple login form in my website. In given requirements stands, that password
Have simple C# console app which imports text data into SQL. It takes around

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.