mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-02-10 23:36:14 -05:00
Added guard to asset helper for missing paths
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
This commit is contained in:
parent
5c8efd087e
commit
9abffe4396
2 changed files with 11 additions and 3 deletions
|
@ -2,14 +2,19 @@
|
|||
// Usage: `{{asset "css/screen.css"}}`
|
||||
//
|
||||
// Returns the path to the specified asset.
|
||||
const proxy = require('./proxy');
|
||||
const {SafeString, metaData, errors, i18n} = require('./proxy');
|
||||
const get = require('lodash/get');
|
||||
const {SafeString} = proxy;
|
||||
const {getAssetUrl} = proxy.metaData;
|
||||
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)
|
||||
);
|
||||
|
|
|
@ -578,6 +578,9 @@
|
|||
"flagMustBeEnabled": "The {flagName} flag must be enabled in labs if you wish to use the \\{\\{{helperName}\\}\\} helper.",
|
||||
"seeLink": "See {url}",
|
||||
"mustBeCalledAsBlock": "The \\{\\{{helperName}\\}\\} helper must be called as a block. E.g. \\{\\{#{helperName}\\}\\} \\{\\{/{helperName}\\}\\}",
|
||||
"asset": {
|
||||
"pathIsRequired": "The \\{\\{asset\\}\\} helper must be passed a path"
|
||||
},
|
||||
"foreach": {
|
||||
"iteratorNeeded": "Need to pass an iterator to #foreach"
|
||||
},
|
||||
|
|
Loading…
Add table
Reference in a new issue