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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T13:19:45+00:00 2026-05-24T13:19:45+00:00

I have a jquery template where I have to combine some variables together like

  • 0

I have a jquery template where I have to combine some variables together like so:

{{= year}}-{{= month}}-{{= day}}-{{= hour}}

I’m coming from jqote templates where you can just use javascript within the template. Is this possible within jquery templating? I can’t find any help on this issue. Thanks.

Also I’m using the weird syntax because groovy doesn’t like ${}.

<script id="mainTemplate" type="text/x-jquery-tmpl">
<ul>        
    {{each(i, wrapSpec) data}}          

    <li><a href="#pkgLineTabs_{{= wrapSpec.wrapSpecId}}" id="{{= wrapSpecId}}">{{= wrapSpec.wrapSpec2.pkgLineId.pkgLineTree.treeId.name}} {{= wrapSpec.shortname}} </a></li>

    {{/each}}
</ul>

{{each(i, wrapSpec) data}}

<div id="pkgLineTabs_{{= wrapSpec.wrapSpecId}}" style="font-size:12px" class="reportTable display {{= wrapSpec.wrapSpec2.pkgLineId.hash}}" title="{{= wrapSpec.wrapSpec2.pkgLineId.hash}}" >    

    {{tmpl(wrapSpec.report) "#dayTemplate"}}

</div>  

{{/each}}

In jqote I could just say var pkgLineId = wrapSpec.wrapSpec2.pkgLineId.

So instead of saying wrapspec.wrapSpec2.pkgLineId.hash I could just put pkgLineId.hash.

  • 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-24T13:19:46+00:00Added an answer on May 24, 2026 at 1:19 pm

    You can use the ${ } Template tag to embed a function or expression in a jQuery template.

    http://api.jquery.com/template-tag-equal/

    You can pass global variables to the template by way of the window object:

    var year = 2011;
    
    var myTemplate = $("<div><b>Year: ${year}</b></div>").template();
    $.tmpl(myTemplate, window).appendTo("#myDiv");
    

    Or:

    var currentDate = {'year' : 2011};
    
    var myTemplate = $("<div><b>Year: ${year}</b></div>").template();
    $.tmpl(myTemplate, currentDate).appendTo("#myDiv");
    

    Here is a jsfiddle that accomplishes what I think you are trying to do: http://jsfiddle.net/GTjXz/1/

    EDIT: jsfiddle which dynamically declares new properties on the $item object in the template: http://jsfiddle.net/GTjXz/2/

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

Sidebar

Related Questions

I have jQuery based template from themeforest and i building on this ASP.NET Web
I have a jQuery template, and I would like to use a KnockOutJS template
I have a jquery template setup like this: <script id='tmpl-video_list' type='text/x-jquery-tmpl'> <li> <a href='${url}'><br/>
Below are some functions i have that use the official jQuery Template plugin and
I have the following jQuery-tmpl template: <script id=month-template type=text/x-jquery-tmpl> <div style=width:${width};> <div>Hello</div> </div> </script>
I have the following KnockoutJS template (render with jquery.tmpl): <script id=contactsTemplate type=text/html> <li data-bind=click:
I have a template set up that I'm making ajax calls to via jQuery.
I have jQuery code which looks something like this on Button1 Click $('table.result_grid tbody
I have the following jQuery template and I need to keep track of the
I am having an issue with jQuery templates. I have a simple template each

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.