0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-02-03 23:00:14 -05:00

Absolute option for {{url}} helper

- pass absolute to {{url}} to get an absolute url rather than a relative one
This commit is contained in:
Hannah Wolfe 2013-09-02 22:06:16 +01:00
parent 1ff9550e1f
commit 552a25018f

View file

@ -44,11 +44,25 @@ coreHelpers = function (ghost) {
return date;
});
// ### URL helper
//
// *Usage example:*
// `{{url}}`
// `{{url absolute}}`
//
// Returns the URL for the current object context
// i.e. If inside a post context will return post permalink
// absolute flag outputs absolute URL, else URL is relative
ghost.registerThemeHelper('url', function (context, options) {
if (models.isPost(this)) {
return "/" + this.slug;
var output = '';
if (options && options.absolute) {
output += ghost.config().env[process.NODE_ENV].url;
}
return '';
if (models.isPost(this)) {
output += "/" + this.slug;
}
return output;
});
// ### Author Helper