Skip to content

Commit

Permalink
Merge pull request #6579 from LaurentGoderre/demos-striphtml-title
Browse files Browse the repository at this point in the history
Demos: Strip HTML from the title tag
  • Loading branch information
LaurentGoderre committed Feb 27, 2015
2 parents c458763 + cb2d196 commit ad6e1ca
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Gruntfile.coffee
Expand Up @@ -429,7 +429,7 @@ module.exports = (grunt) ->
sanitize: false
production: false
data: "site/data/**/*.{yml,json}"
helpers: "site/helpers/helper-*.js"
helpers: "site/helpers/helper{,s}-*.js"
layoutdir: "site/layouts"
partials: "site/includes/**/*.hbs"
layout: "default.hbs"
Expand Down
32 changes: 32 additions & 0 deletions site/helpers/helpers-striptags.js
@@ -0,0 +1,32 @@
/**
* Handlebars Helpers: strip html tags
* TODO: Remove when https://github.com/assemble/handlebars-helpers/pull/179 lands
*/
'use strict';


// The module to be exported
var helpers = {


/**
* {{striphtml}}
* @author: Laurent Goderre <https://github.com/LaurentGoderrre>
* @param {Object} options
* @return {String}
*/
striptags: function (options) {
return options.fn(this).replace(/<[^>]*?>/g, "");
}
};


// Export helpers
module.exports.register = function (Handlebars, options) {
options = options || {};
for (var helper in helpers) {
if (helpers.hasOwnProperty(helper)) {
Handlebars.registerHelper(helper, helpers[helper]);
}
}
};
2 changes: 1 addition & 1 deletion site/includes/pagetitle.hbs
@@ -1,4 +1,4 @@
{{title}}
{{#striptags}}{{{title}}}{{/striptags}}
{{#contains page.src "/demos/index"}}
{{else}}
{{#contains page.src "/docs/"}}
Expand Down

0 comments on commit ad6e1ca

Please sign in to comment.