mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-25 03:44:29 +03:00
HTML helpers work with double taches - issue #246 item 1.
- updated navigation and pagination helpers to use SafeString - nav and pagination don't need triple taches any more - nav tests updated, and renamed to match helper name
This commit is contained in:
parent
1a99aa8c6f
commit
53fe5e3ba3
@ -3,6 +3,7 @@ var fs = require('fs'),
|
||||
_ = require('underscore'),
|
||||
handlebars = require('express-hbs').handlebars,
|
||||
nodefn = require('when/node/function'),
|
||||
|
||||
NavHelper;
|
||||
|
||||
NavHelper = function (navTemplate) {
|
||||
@ -29,11 +30,7 @@ NavHelper.prototype.compileTemplate = function (templatePath) {
|
||||
};
|
||||
|
||||
NavHelper.prototype.renderNavItems = function (navItems) {
|
||||
var output;
|
||||
|
||||
output = this.navTemplateFunc({links: navItems});
|
||||
|
||||
return output;
|
||||
return new handlebars.SafeString(this.navTemplateFunc({links: navItems}));
|
||||
};
|
||||
|
||||
// A static helper method for registering with ghost
|
||||
|
@ -20,7 +20,7 @@ PaginationHelper = function (paginationTemplate) {
|
||||
PaginationHelper.prototype.compileTemplate = function (templatePath) {
|
||||
var self = this;
|
||||
|
||||
|
||||
// Allow people to overwrite the paginationTemplatePath
|
||||
templatePath = templatePath || this.paginationTemplatePath;
|
||||
|
||||
return nodefn.call(fs.readFile, templatePath).then(function (paginationContents) {
|
||||
@ -29,12 +29,10 @@ PaginationHelper.prototype.compileTemplate = function (templatePath) {
|
||||
});
|
||||
};
|
||||
|
||||
PaginationHelper.prototype.renderPagination = function (context, options) {
|
||||
var output = this.paginationTemplateFunc(context);
|
||||
return output;
|
||||
PaginationHelper.prototype.renderPagination = function (context) {
|
||||
return new handlebars.SafeString(this.paginationTemplateFunc(context));
|
||||
};
|
||||
|
||||
|
||||
PaginationHelper.registerWithGhost = function (ghost) {
|
||||
var templatePath = path.join(ghost.paths().frontendViews, 'pagination.hbs'),
|
||||
paginationHelper = new PaginationHelper(templatePath);
|
||||
|
@ -37,7 +37,7 @@ describe('Navigation Helper', function () {
|
||||
|
||||
// Returns a string returned from navTemplateFunc
|
||||
should.exist(rendered);
|
||||
rendered.should.equal("rendered 2");
|
||||
rendered.string.should.equal("rendered 2");
|
||||
|
||||
templateSpy.calledWith({ links: fakeNavItems }).should.equal(true);
|
||||
});
|
Loading…
Reference in New Issue
Block a user