mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-11-29 15:12:58 +03:00
677502813e
closes #6629 - i had the case that in gravatar process.env.NODE_ENV was undefined and indexOf of undefined crashe my application - so always use config to read current env
33 lines
1.1 KiB
JavaScript
33 lines
1.1 KiB
JavaScript
var _ = require('lodash'),
|
|
config = require('../config'),
|
|
utils;
|
|
|
|
utils = {
|
|
assetTemplate: _.template('<%= source %>?v=<%= version %>'),
|
|
linkTemplate: _.template('<a href="<%= url %>"><%= text %></a>'),
|
|
scriptTemplate: _.template('<script src="<%= source %>?v=<%= version %>"></script>'),
|
|
inputTemplate: _.template('<input class="<%= className %>" type="<%= type %>" name="<%= name %>" <%= extras %> />'),
|
|
isProduction: config.get('env') === 'production',
|
|
// @TODO this can probably be made more generic and used in more places
|
|
findKey: function findKey(key, object, data) {
|
|
if (object && _.has(object, key) && !_.isEmpty(object[key])) {
|
|
return object[key];
|
|
}
|
|
|
|
if (data && _.has(data, key) && !_.isEmpty(data[key])) {
|
|
return data[key];
|
|
}
|
|
|
|
return null;
|
|
},
|
|
parseVisibility: function parseVisibility(options) {
|
|
if (!options.hash.visibility) {
|
|
return ['public'];
|
|
}
|
|
|
|
return _.map(options.hash.visibility.split(','), _.trim);
|
|
}
|
|
};
|
|
|
|
module.exports = utils;
|