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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T03:21:02+00:00 2026-06-06T03:21:02+00:00

I am using the _.template() function of underscorejs together with backbonejs. When using underscore.js

  • 0

I am using the _.template() function of underscorejs together with backbonejs. When using underscore.js v1.3.0, I could use an if statement as shown:

<script type="text/template" id="tpl_listing_list_item">
    <% if(<%= address_2 %>){%>, <%= address_2 %><%}%>
</script>

Problem: After updating to v1.3.3, I get the error Uncaught SyntaxError: Unexpected token ILLEGAL in the Javascript console. Has this feature been removed? Removing the if code fixes the error. If it’s removed, is there another way to achieve the same thing?

  • 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-06T03:21:04+00:00Added an answer on June 6, 2026 at 3:21 am

    In your if statement you’ve already escaped into interpolation mode, so the <%= is an illegal character.

    This works when I use it in my browser with 1.3.3

    <script type="text/template" id="tpl_listing_list_item">
        <% if(address_2){ %>, <%= address_2 %> <% } %>
    </script>
    

    Example:

    var t = _.template('{% if(address_2){ %}, {{ address_2 }} {% } %}')
    undefined
    t({'address_2': 'test'});
    ", test "
    

    (We use JSP so our template tags are {% %}, {{ }}, and {%- %} instead of the defaults, so excuse my tags)

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

Sidebar

Related Questions

I'm using the underscore.js templating function and have done a template like this: <script
After loading a PHP template (using jQuery's load function), this simple script won't make
Possible Duplicate: trailing return type using decltype with a variadic template function I want
Possible Duplicate: trailing return type using decltype with a variadic template function I'm getting
I have the following backbone.js client side template: <script id=calleeTemplate type=text/x-jquery-tmpl> <tr style=background-color: ${StatusColour}>
Can I use variadic templates without using the template parameters as function parameters? When
I am using a template function and I am passing and I may be
I'm trying to define a function using template template parameters (I just want to
I have template function compare defined as below. #include<iostream> using namespace std; template<typename T>
I am using razor template and following is the scenario $(function(){ //if (ViewBag.IsCallFunction){ somefunction();

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.