mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-13 14:39:52 +03:00
9abffe4396
refs #10496 - currently {{asset this/is/not/a.string}} would throw a 500 error - this commit changes that to make it throw a sensible 400 + incorrect usage error
22 lines
570 B
JavaScript
22 lines
570 B
JavaScript
// # Asset helper
|
|
// Usage: `{{asset "css/screen.css"}}`
|
|
//
|
|
// Returns the path to the specified asset.
|
|
const {SafeString, metaData, errors, i18n} = require('./proxy');
|
|
const get = require('lodash/get');
|
|
const {getAssetUrl} = metaData;
|
|
|
|
module.exports = function asset(path, options) {
|
|
const hasMinFile = get(options, 'hash.hasMinFile');
|
|
|
|
if (!path) {
|
|
throw new errors.IncorrectUsageError({
|
|
message: i18n.t('warnings.helpers.asset.pathIsRequired')
|
|
});
|
|
}
|
|
|
|
return new SafeString(
|
|
getAssetUrl(path, hasMinFile)
|
|
);
|
|
};
|