mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-01-06 22:40:14 -05:00
870bf27394
- i18n is an old pattern that failed - we are slowly replacing i18n with the tpl helper
25 lines
648 B
JavaScript
25 lines
648 B
JavaScript
// # Asset helper
|
|
// Usage: `{{asset "css/screen.css"}}`
|
|
//
|
|
// Returns the path to the specified asset.
|
|
const {SafeString, metaData, errors, tpl} = require('../services/proxy');
|
|
const get = require('lodash/get');
|
|
const {getAssetUrl} = metaData;
|
|
|
|
const messages = {
|
|
pathIsRequired: 'The {{asset}} helper must be passed a path'
|
|
};
|
|
|
|
module.exports = function asset(path, options) {
|
|
const hasMinFile = get(options, 'hash.hasMinFile');
|
|
|
|
if (!path) {
|
|
throw new errors.IncorrectUsageError({
|
|
message: tpl(messages.pathIsRequired)
|
|
});
|
|
}
|
|
|
|
return new SafeString(
|
|
getAssetUrl(path, hasMinFile)
|
|
);
|
|
};
|