8d88f5b6a5
closes #7826 - expose raw url value inside `{{navigation}}` helper - modify `{{url}}` helper to urlencode values and mark as HTML-safe to avoid Handlebars additional HTML-escaping
20 lines
551 B
JavaScript
20 lines
551 B
JavaScript
// # URL helper
|
|
// Usage: `{{url}}`, `{{url absolute="true"}}`
|
|
//
|
|
// Returns the URL for the current object scope i.e. If inside a post scope will return post permalink
|
|
// `absolute` flag outputs absolute URL, else URL is relative
|
|
|
|
var hbs = require('express-hbs'),
|
|
getMetaDataUrl = require('../data/meta/url');
|
|
|
|
function url(options) {
|
|
var absolute = options && options.hash.absolute,
|
|
url = getMetaDataUrl(this, absolute);
|
|
|
|
url = encodeURI(decodeURI(url));
|
|
|
|
return new hbs.SafeString(url);
|
|
}
|
|
|
|
module.exports = url;
|