下划线不替换变量

underscore doesn't replace variables

我在 js 中有以下行:

 terminalsListHtml += this.compiled(_.extend(this.terminals[i], {clazz: 'all'}, obj));

我调试了以下代码:

尝试评估_.extend(this.terminals[i], {clazz: 'all'}, obj)

看起来不错

但尝试评估

this.compiled(_.extend(this.terminals[i], {clazz: 'all'}, obj));

这不是我期望的结果。

请帮助解决所描述的问题。

P.S.

window.MARC = {
        addTerminalPage: {
            ....
            compiled: _.template($('#terminal-template').text()),



<script type="text/template" id="terminal-template">
    <li data-terminal-id="{{ id }}" class="{{ clazz2 }}">
        <label>
            <input type="checkbox" name="terminal" class="{{ clazz }}" data-terminal-id="{{ id }}" />
            <a href="#" title="" class="image"><img
                    src="<c:url value='/resources/images/img1.png'/>"
                    alt=""/></a>

            <h3>{{ name }}
                <small>{{ place }}</small>
            </h3>
            <p>{{ description }}</p>

            <p class="count">Проходимость: <span>{{ count }}</span> чел./час</p>

            <p class="count">Стоимость: <span>{{ amount }}</span> руб./час</p>
        </label>
    </li>
</script>

P.S.

_.templateSettings = {
        interpolate: /\{\{(.+?)\}\}/gim,
        evaluate: /\{\{(.+?)\}\}/gim,
        escape: /\{\{\-(.+?)\}\}/gim
    };

搬家后正常工作

<script type="text/javascript">
    _.templateSettings = {
        interpolate: /\{\{(.+?)\}\}/gim,
        evaluate: /\{\{(.+?)\}\}/gim,
        escape: /\{\{\-(.+?)\}\}/gim
    };
</script>

在文件开头