mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-20 01:03:23 +03:00
e96b60b850
refs #6534 - this PR assumes that we are now saving usernames only in the database for twitter & facebook - adds a new social links utility which can generate twitter & facebook urls from the username - adds a {{twitter_url}} and {{facebook_url}} helper which uses these - adds a full suite of tests for the helpers & utils
25 lines
860 B
JavaScript
25 lines
860 B
JavaScript
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>'),
|
|
inputTemplate: _.template('<input class="<%= className %>" type="<%= type %>" name="<%= name %>" <%= extras %> />'),
|
|
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;
|
|
}
|
|
};
|
|
|
|
module.exports = utils;
|