我的 /routes/index.coffee 文件中有这段代码:
exports.Dropbox = (req, res) ->
production = if process.env['NODE_ENV'] == "production" then true
if production
mixpanelId = PROD_MIXPANEL_ID
res.render 'connectors/Dropbox', { title: 'About Dropbox', mixpanelId: mixpanelId, production: production }
exports.Box = (req, res) ->
production = if process.env['NODE_ENV'] == "production" then true
if production
mixpanelId = PROD_MIXPANEL_ID
res.render 'connectors/Box', { title: 'About Box', mixpanelId: mixpanelId, production: production }
它被许多不同的提供者复制了很多次。任何想法如何在某种函数或数组中复制它,所以我不需要多次声明它?