Last active
December 21, 2015 11:19
-
-
Save tilomitra/6298456 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
exports.sectionHeading = function (title) { | |
return Handlebars.helpers.anchor.call(this, "h2", "content-subhead"); | |
}; | |
exports.anchor = function (title, elemType, classes) { | |
var elem, | |
anchor = title.toLowerCase() | |
.replace(/&[^\s;]+;?/g, '') // remove HTML entities | |
.replace(/[^\s\w\-]+/g, '') // remove all chars except whitespace, word chars, and - | |
.replace(/\s+/g, '-'); | |
typeof elemType === 'string' || (elemType = 'h2'); | |
typeof classes === 'string' || (classes = 'content-subhead'); | |
elem = '<' + elemType + ' id="' + anchor + '" class="' + classes + '">' + title + '</' + elemType + '>'; | |
return new Handlebars.SafeString(elem); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment