NuclearPeon
NuclearPeon

Reputation: 6059

Underscore.js: TypeError: rc is undefined when using templates

I'm using underscore.js to create templates. I am utilizing the rc variable discussed here and I'm getting rc is undefined messages in my firebug console along with this tidbit:

((__t=( rc.siteid ))==null?'':_.escape(__t))+

I tried sending in empty json as specified like so: var mytemplate = _.template([code], {}) as the issue comment suggested, but the error still persists and my templates don't work.

Upvotes: 0

Views: 163

Answers (1)

NuclearPeon
NuclearPeon

Reputation: 6059

The solution for me was to always explicitly send in an empty json {} if I didn't have any options to send in. The code would look like this:

var mytemplate = _.template([code]);
$('body').append(mytemplate({})); 

I'm creating this question/answer because I did not find a solution on SO or via google.

Upvotes: 0

Related Questions