mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-11-29 07:09:48 +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
27 lines
719 B
JavaScript
27 lines
719 B
JavaScript
// # Asset helper
|
|
// Usage: `{{asset "css/screen.css"}}`, `{{asset "css/screen.css" ghost="true"}}`
|
|
//
|
|
// Returns the path to the specified asset. The ghost flag outputs the asset path for the Ghost admin
|
|
|
|
var config = require('../config'),
|
|
getAssetUrl = require('../data/meta/asset_url'),
|
|
hbs = require('express-hbs');
|
|
|
|
function asset(path, options) {
|
|
var isAdmin,
|
|
minify;
|
|
|
|
if (options && options.hash) {
|
|
isAdmin = options.hash.ghost;
|
|
minify = options.hash.minifyInProduction;
|
|
}
|
|
if (config.get('env') !== 'production') {
|
|
minify = false;
|
|
}
|
|
return new hbs.handlebars.SafeString(
|
|
getAssetUrl(path, isAdmin, minify)
|
|
);
|
|
}
|
|
|
|
module.exports = asset;
|