エロサイトの作り方

2013年11月から勉強しながらエロサイトを作っています。

Underscore.jsのtemplateが1.7から仕様が変わってて死んだ件

なんで突然互換性が無くなる変更するのよ…

1.6.0まで

_.template('this is a <%- name %>.', {name:'tits'});
this is a tits.

1.7.0

_.template('this is a <%- name %>.', {name:'tits'});
function (data) {
      return render.call(this, data, _);
    }

なんか関数が返ってきてますが…

Change Log

1.7.0 — August 26, 2014

Underscore templates no longer accept an initial data object. _.template always returns a function now.

Underscore.js

これかー。

1.7(正しい使い方)

var template = _.template('this is a <%- name %>.');
template({name:'tits'});
this is a tits.

一行で書けなくなった。無理矢理一行にするなら、

_.template('this is a <%- name %>.')({name:'tits'});

こうなるけど、なんかしょっぱい。