2014-10-10 09:54:07 -05:00
|
|
|
// # 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
|
2017-04-04 11:07:35 -05:00
|
|
|
var proxy = require('./proxy'),
|
|
|
|
config = proxy.config,
|
|
|
|
getAssetUrl = proxy.metaData.getAssetUrl,
|
|
|
|
SafeString = proxy.SafeString;
|
2014-10-10 09:54:07 -05:00
|
|
|
|
2017-04-04 11:07:35 -05:00
|
|
|
module.exports = function asset(path, options) {
|
2016-01-17 05:07:52 -05:00
|
|
|
var isAdmin,
|
2015-03-08 12:09:57 -05:00
|
|
|
minify;
|
|
|
|
|
|
|
|
if (options && options.hash) {
|
|
|
|
isAdmin = options.hash.ghost;
|
|
|
|
minify = options.hash.minifyInProduction;
|
|
|
|
}
|
2017-02-03 13:25:39 -05:00
|
|
|
|
|
|
|
if (config.get('minifyAssets') === false) {
|
2016-01-17 05:07:52 -05:00
|
|
|
minify = false;
|
2015-03-08 12:09:57 -05:00
|
|
|
}
|
2017-02-03 13:25:39 -05:00
|
|
|
|
2017-04-04 11:07:35 -05:00
|
|
|
return new SafeString(
|
2016-02-21 13:48:44 -05:00
|
|
|
getAssetUrl(path, isAdmin, minify)
|
2016-01-17 05:07:52 -05:00
|
|
|
);
|
2017-04-04 11:07:35 -05:00
|
|
|
};
|