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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T14:26:44+00:00 2026-05-28T14:26:44+00:00

I’m using backbone’s underscore templating engine with the mustache formatting patterns. I have already

  • 0

I’m using backbone’s underscore templating engine with the mustache formatting patterns.

I have already been successfully using it elsewhere in the project but now for the first time I’m using the looping list patterns from mustache to populate the template which is throwing an error which I’m a bit baffled by.
The error in chrome is:

"Uncaught SyntaxError: Unexpected token ILLEGAL"

and points to underscore’s template function in the backtrace, which is pretty useless but in firebug i get a more helpful error like this:

enter image description here

Suggesting that the hash symbol ‘#’ is the issue, which would make sense as I know that mustache is working ok as there are many other parts of the project using it well, also this is the first time I’m using the hash sybol in my templates.It looks like a problem either with the looping feature or with the interpolation/template settings for underscore.

Here’s the relevant piece of my template:

<div class="thumblist thumblistleft" id="currentprojectslist">
    <div class="thumb-list-header">
         <h2>current projects</h2>
    </div>
    <div class="thumb-list-area">
        <ol>
        {{#worklist}}       <!----- LOOK HERE --->
            {{#current}}
              <li><a>{{title}}</a></li>
            {{/current}}
        {{/worklist}}
        </ol>
    </div>
</div>

and here’s a sample of the JSON (which all validates fine)

{blah blah blah lot in here before,"worklist":[{"thumb":"img/project-s.jpg","id":"340","title":"Test Project One","desc":"big load of content here","current":true}], and so on....}

I was initially following this example here for reference:
http://mustache.github.com/#demo

NOW HERES WHERE I THINK THE PROBLEM MIGHT BE:

underscore.js suggests using this before rendering a mustache template:

_.templateSettings = {
     evaluate : /\{\[([\s\S]+?)\]\}/g,
     interpolate : /\{\{([\s\S]+?)\}\}/g
};

also:

interpolate : /\{\{(.+?)\}\}/g

Also just the interpolate statement, ive tried both. However my regex knowledge is really poor and I have a feeling it might not accomodate the hash? At any rate…. I’m totally stumped.
Can someone help me out here?

is it even possible to loop like this? looking at underscore source i’m not sure:
http://documentcloud.github.com/underscore/docs/underscore.html#section-120

Thanks very 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-28T14:26:45+00:00Added an answer on May 28, 2026 at 2:26 pm

    I’m posting for the sakes of anyone else facing this issue.
    After a lot of googling to no avail, i went through the underscore.js source with a fine toothed comb and basically you have to either use underscore’s template syntax, writein ugly function processors into your JSON or include mustache.js into your source and call:

    Mustache.render(mytemplate,mymodel)
    

    and foresake underscore’s

    _.template(..) function
    

    Annoying but whatever, I hope that helps someone

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

Sidebar

Related Questions

I have a jquery bug and I've been looking for hours now, I can't
I have thousands of HTML files to process using Groovy/Java and I need to
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
That's pretty much it. I'm using Nokogiri to scrape a web page what has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
this is what i have right now Drawing an RSS feed into the php,
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I have a French site that I want to parse, but am running into
We're building an app, our first using Rails 3, and we're having to build

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.