Skip to content

Commit

Permalink
HTML helpers work with double taches - issue TryGhost#246 item 1.
Browse files Browse the repository at this point in the history
- 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
  • Loading branch information
ErisDS committed Jul 11, 2013
1 parent 1a99aa8 commit 53fe5e3
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 11 deletions.
7 changes: 2 additions & 5 deletions core/frontend/helpers/navigation.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ var fs = require('fs'),
_ = require('underscore'),
handlebars = require('express-hbs').handlebars,
nodefn = require('when/node/function'),

NavHelper;

NavHelper = function (navTemplate) {
Expand All @@ -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
Expand Down
8 changes: 3 additions & 5 deletions core/frontend/helpers/paginate.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
Expand Down

0 comments on commit 53fe5e3

Please sign in to comment.