Yeoman を使用してジェネレーターを作成しています。Yeoman は underscore.js テンプレートを使用します。
特定のファイルには、次のコードがあります。
var
<% _.each(requires, function(require) { %>
<% if(require.shouldApply) { %>
<%= _.camelize(require.name) %> = require('<%= require.name %>'),
<% } %>
<% }); %>
mongoose = require('mongoose'),
Schema = mongoose.Schema;
場合によっては false であることを考えるとrequire.shouldApply
、空白行を生成したくありません。
たとえば、入力の場合、次のrequires: [{shouldApply: false, name: 'zoo'}, {shouldApply: false, name: 'foo'}, {shouldApply: true, name: 'bar'}]
ようになります。
var
zoo = require('zoo'), //note that the line below is blank
bar = require('bar'), //I don't want the blank line above
mongoose = require('mongoose'),
Schema = mongoose.Schema;
underscore.js テンプレートがこれらの望ましくない空白行を作成するのを防ぐ方法を知っている人はいますか?