January 2018
Beginner
658 pages
13h 10m
English
Helpers can also take arguments, and this is really useful. Let's create a second helper that's going to be a capitalization helper. We'll call the helper screamIt and its job will be to take some text and it will return that text in uppercase.
In order to do this, we will be calling hbs.registerHelper again. This helper will be called screamIt, and it will take a function because we do need to run some code in order to do anything useful:
hbs.registerHelper('getCurrentYear', () => { return new Date().getFullYear()});hbs.registerHelper('screamIt', () => {});
Now screamIt is going to take text to scream and all it will do is call on that string the toUpperCase method. We'll return text.toUpperCase, just like this:
hbs.registerHelper('screamIt', ...Read now
Unlock full access