2014-10-10 18:54:07 +04:00
|
|
|
var _ = require('lodash'),
|
|
|
|
utils;
|
|
|
|
|
|
|
|
utils = {
|
|
|
|
assetTemplate: _.template('<%= source %>?v=<%= version %>'),
|
|
|
|
linkTemplate: _.template('<a href="<%= url %>"><%= text %></a>'),
|
|
|
|
scriptTemplate: _.template('<script src="<%= source %>?v=<%= version %>"></script>'),
|
2015-05-13 12:26:49 +03:00
|
|
|
inputTemplate: _.template('<input class="<%= className %>" type="<%= type %>" name="<%= name %>" <%= extras %> />'),
|
2016-05-17 16:06:12 +03:00
|
|
|
isProduction: process.env.NODE_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;
|
2016-06-11 14:49:08 +03:00
|
|
|
},
|
|
|
|
parseVisibility: function parseVisibility(options) {
|
|
|
|
if (!options.hash.visibility) {
|
|
|
|
return ['public'];
|
|
|
|
}
|
|
|
|
|
|
|
|
return _.map(options.hash.visibility.split(','), _.trim);
|
2016-05-17 16:06:12 +03:00
|
|
|
}
|
2014-10-10 18:54:07 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
module.exports = utils;
|