Using Django for Underscore and Backbone templating

When I define my JavaScript templates within:

<script type="text/template">
</script>

they are not rendered in the HTML (I don't see them on the page) in my Django application. Could one of the filters or middlewares I have declared be excluding them?

This is from settings.py

COMPRESS_PRECOMPILERS = (
    ('text/less', 'lessc {infile} {outfile}'),
)
if DEBUG:
    COMPRESS_REBUILD_TIMEOUT = 1

TEMPLATE_CONTEXT_PROCESSORS = (
     "django.core.context_processors.request",
     "django.contrib.auth.context_processors.auth",
     "django.core.context_processors.debug",
     "django.core.context_processors.i18n",
     "django.core.context_processors.media",
     "django.core.context_processors.static",
     "django.core.context_processors.tz",
     "django.contrib.messages.context_processors.messages",
)


MIDDLEWARE_CLASSES = (
    'django.middleware.common.CommonMiddleware',
    'django.contrib.sessions.middleware.SessionMiddleware',
    'django.middleware.csrf.CsrfViewMiddleware',
    'django.middleware.transaction.TransactionMiddleware',
    'django.contrib.auth.middleware.AuthenticationMiddleware',
    'django.contrib.messages.middleware.MessageMiddleware',
    'debug_toolbar.middleware.DebugToolbarMiddleware',
    # Uncomment the next line for simple clickjacking protection:
    # 'django.middleware.clickjacking.XFrameOptionsMiddleware',
)

If so, how can I solve this?

EDIT The template:

<script type="text/template" id="new-catalog-template">

    <div class="catalog" data-id="<%= responseJSON.catalog.id %>" style="display: none">
        <div class="catalog-main-content">
            <div class="preview"><img src="<%= responseJSON.user_dir %>/catalogs/<%= responseJSON.catalog.id %>/ipad-preview-icon-large.png" alt="" /></div>
            <div class="name"><%= responseJSON.catalog.name %></div>
            <div class="last-build"><em>Last build:</em><%= responseJSON.catalog.last_build_natural %> (<%= responseJSON.catalog.last_build %>)</div>
            <div class="description"><%= responseJSON.catalog.description %></div>
        </div>
    </div>

</script>

** EDIT EDIT **

Oops, the script tag was outside the main block and therefore not rendered ¬_¬ ... Thank you for mentioning {{ verbatim }}, by the way

Answer №1

Would you mind sharing that template with me?

If not, maybe you could consider using the escapejs-Filter or the latest verbatim tag as alternative solutions.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

I'm looking to efficiently convert JSON or GeoJSON data into a Backbone model and then seamlessly transition that model into a Leaflet layer. Can anyone provide guidance on

As I work on refining layer definitions that can be added individually to a collection, my goal is to smoothly render the view or add them to a L.LayerGroup using the leaflet api. However, being new to JavaScript, I am uncertain about how to map the proper ...

What could be causing the EBUSY: resource busy or locked, open errno: -4082 error to appear while trying to build storybook 7 in next.js 13?

While attempting to create a storybook, I encountered the following error in my project: [Error: EBUSY: resource busy or locked, open 'C:\Users\ali\Desktop\Works\Design Systems\projects\storybook-test2\node_modu ...

The ReactJS hamburger menu fails to function after being clicked

I'm facing an issue with my responsive navbar. Whenever I click the hamburger menu, it directs me to a blank white page without any content. Can someone help me identify the problem? I am new to react and believe I might need to explore another approa ...

Using Javascript and Node.js to send a JSON request

While browsing through this particular question, I came across a method in node.js to distinguish between html requests and json requests: app.get('/route', function (req, res) { if (req.is('json')) res.json(data); else if (req ...

A method to retrieve the content of an input field and assign it to an onclick event

I encountered an issue with an ajax function that requires the lat and lng variables. Here is a simple HTML code snippet: <fieldset> <legend>Geocoding Services</legend> Latitude:<br><input type="text" id="lat" value="42.3600077 ...

Converting Vue HTML to PDF without relying on html2canvas functionality

My current challenge involves creating a PDF file from either HTML or Vue component. I have experimented with various libraries such as jsPDF, html2pdf, and vue-html2pdf, but it seems like they all rely on html2canvas, causing the UI to freeze for a few ...

My objective is to show the div element just once using AngularJS

Here's the scenario I want to show this div just once, not multiple times: //angular js code $scope.arr=["sunday","mpnday","tuesday"]; //html view <ul> <li ng-repeat="x in arr"> <div><p>{{ x }}</p> </div> & ...

Checking for the existence of an object while passing variables in jade - a comprehensive guide

Leveraging the power of Jade, passing an object to the client can be achieved in this way: Route: res.render('mypage', { title: 'My Page', myobject : data }); Jade Template: extends layout block navbar include includes/navbar ...

Toggle a jQuery bar based on the presence of a specific CSS class

I am working on a feature where I can select and deselect images by clicking on a delete button. When an image is selected, a bar appears at the top. If I click the same delete button again, the image should be deselected and the bar should disappear. This ...

Struggling with updating state using splice method within an onClick event in React Hooks

CODE DEMO I'm facing an issue with my code snippet where it appears fine when I console.log it, but fails to set the state. The goal is to delete a box by using splice when clicked, however, something seems to be preventing it from working properly. ...

Changing the theme of a toggle button in Jquery Mobile when the button is pressed

I have a group of buttons with a specific class <div class="prog-day"> <div class="prog-clear" data-role="controlgroup" data-type="horizontal> <a href="#" data-role="button" data-mini="true" data-theme="b">Clear</a> ...

Challenge with Expect.js validation in a lesson on Codeacademy

I am currently developing a lesson on Codecademy to teach users about the construction of HTML forms. This project is mainly for my own enjoyment, just to keep everyone in the loop. After reviewing the submission test guidelines and API, I made the decisio ...

Unexpected issue encountered when working with JSON in Node.js

I've searched through countless solutions on stackoverflow, but none of them seem to work for me. It's really frustrating not understanding what's going wrong. Below is the code I'm having trouble with: var data = ""; req.on('dat ...

Implementation of SpotLight rotation using three.js

Currently, I am attempting to rotate a spotlight using the following code: var light = new THREE.SpotLight( color, intensity, distance ); light.position.set( 0, 100, 0 ); light.rotation.set( 0, Math.PI, 0 ); light.shadowCameraFar = 50; light.shadowCamer ...

Convert an AJAX JSON object into values for multiple text boxes

When making an ajax call, I receive the following JSON input: var json = { "id_u":"1", "nombre_usuario":"JESUS", "apellido_paterno_usuario":"DIAZ", } I have text inputs that correspond to each key in the JSON object: <input type="text" name="id ...

What is the best way to implement CSS rules for a hidden submenu?

Can anyone help me figure out how to apply CSS rules for a hidden submenu? I've attempted to use some JavaScript, but it's not working as expected. Below is a sample of the code I'm working with. The idea is that when you click on the anchor ...

Combining numerous base64 decoded PDF files into a single PDF document with the help of ReactJS

I have a scenario where I receive multiple responses in the form of base64 encoded PDFs, which I need to decode and merge into one PDF file. Below is the code snippet for reference: var pdf_base1 = "data:application/pdf;base64,JVBERi0xLjQKJfbk/N8KMSAwIG9 ...

Can ajax requests be made without a web browser?

Currently, I am in the process of developing JavaScript tests using mocha and chutzpah, which means conducting all my tests without a browser. However, I have encountered an issue where all my AJAX calls are resulting in empty strings. Even when using the ...

I'm struggling to understand how to properly utilize the "path" parameter in the app.use() function. The outcome it produces is not what I had anticipated

I am a beginner in express.js and I have been trying to understand how to properly use "path" in the app.use() function. However, when I execute the code as shown below, the result is not what I anticipated and it's quite confusing for me. Can you ple ...

Superbase Email Forwarding

Is it possible to create a dynamic redirect link in the confirmation email that directs users to a specific page after creating an account? For instance: If a user visits the website using a link such as www.website.com/project/1 or /project/2 etc. and t ...