Skip to content

How to include underscore (or other) templates OR: how to add id to = javascript #80

@th-lange

Description

@th-lange

I am currently trying to include an underscore template using ace.
I need to give 1. an id to the script and it should not be escaped...

This is the template:

<script type="text/template" id="result-row">
    {% _.each(results, function(result,key,arr) { %}
        <tr onclick="getBook( {%= result.id %} )">
            <td>{%= result.id %}</td>
            <td>{%= result.title %}</td>
            <td>{%= result.author%}</td>
            <td>{%= result.year%}</td>
        </tr>
    {% }); %}
</script>

The script tag

If I use the script tag, I can assign a id attribute, like this:

script id="result-row" type="text/javascript"

But this results in the "<" and ">" beeing escaped and tags added like this:

<script id="result-row" type="text/javascript"><{%>_.each(results, function(result,key,arr) { %}<<tr onclick=""getBook( {%= result.id %} )">"><<td>{%=>result.id %}</td></<td>{%=><<td>{%=>result.title %}</td></<td>{%=><<td>{%=>result.author%}</td></<td>{%=><<td>{%=>result.year%}</td></<td>{%=></<tr><</tr>></</tr>></{%><{%>}); %}</{%></script>

Using the = javascript syntax

In this case all is fine. Exept: I am not able to assign an id to the javascript element.
Beeig able to add attributes to = javascript would actually fix this

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions