Yeoman을 사용하여 생성기를 만들고 있는데,이 생성기는 underscore.js 템플릿을 사용합니다. underscore.js 템플릿이 원하지 않는 빈 줄을 만드는 것을 방지하려면 어떻게해야합니까?
var
<% _.each(requires, function(require) { %>
<% if(require.shouldApply) { %>
<%= _.camelize(require.name) %> = require('<%= require.name %>'),
<% } %>
<% }); %>
mongoose = require('mongoose'),
Schema = mongoose.Schema;
이
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 템플릿을 방지하는 방법을 알고 있나요?
'if' 문 (내용 포함)을 모두 한 줄에 넣으면 여분의 줄이 생깁니 까? – ArrayKnight