-1

テンプレートに渡そうとしているデータは、アンダースコアのテンプレート rendererに到達すると、不可解に無視されます。

データは利用可能です:

失敗する直前の開発コンソールのunderscore.js

urlそれでも、パラメーターが未定義であるという例外がコンソールに表示されます。

Uncaught ReferenceError: URL が定義されていません

もう少し掘り下げると、おかしな JavaScript にたどり着きます。

テンプレート上の UnderscoreJS のレンダラー

次の直後に失敗します: __p+='\n\t\t<a href="#'+(noticeurllabelare still both defined)。

4

1 に答える 1

1

Normally there would be a with(obj||{}) in the compiled template. I don't see one in yours so perhaps the variable option is in use somewhere:

By default, template places the values from your data in the local scope via the with statement. However, you can specify a single variable name with the variable setting.

For example, if you:

var t = _.template('<%= x %>');

and then look at t.source, you'll see a function like this (formatted for clarity):

function(obj){
    //...
    with(obj||{}){
        //...
    }
    return __p;
}

but if you say:

var t = _.template('<%= x %>', null, { variable: 'E' });

and look at t.source, you'll see the same structure without the with block around the guts of the function.

Demo: http://jsfiddle.net/ambiguous/jrEub/

The structure of the template function suggests that you have {variable: 'E'} somewhere so your template should be look at <% E.url %> and such instead of just <% url %>.

于 2013-12-07T19:21:14.843 に答える