mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-14 18:52:05 +03:00
10fc320cc8
no issue - In Ghost, 'context' means the page or section of a blog we're currently within when rendering a theme, e.g. 'post' or 'tag' or 'home'. - In handlebars 'context' refers to the blob of JSON that is tied to a template. - These two uses of the word 'context' have gotten very confusing, so I've removed all usage of 'context' within the Ghost handlebars helpers, EXCEPT where they actually refer to the current context (e.g. the is helper)
26 lines
687 B
JavaScript
26 lines
687 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 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 (process.env.NODE_ENV !== 'production') {
|
|
minify = false;
|
|
}
|
|
return new hbs.handlebars.SafeString(
|
|
getAssetUrl(path, isAdmin, minify)
|
|
);
|
|
}
|
|
|
|
module.exports = asset;
|