var hbs = require('express-hbs'),
	config = require('./core/server/config'),
	helpers;

helpers = [

	{
		name: 'title_italics',
		fn: () => {
			// # Title Italics Helper
			// Usage: `{{title_italics <string>}}`
			//
			// My little custom helper for auto-formatting the
			// blog title when it's separated by a period

			var title, 
				split;

			title = config.theme.title || '';
			split = title.split('.');

			if ( split.length > 1 ) 
				output = split.slice(0, -1).join('.') + '<i>.' + split.slice(-1)[0] + '</i>';
			else
				output = title;

    		return new hbs.handlebars.SafeString(output);
		}
	}

];

module.exports = function() {
	helpers.map(helper => {
		hbs.registerHelper(helper.name, helper.fn);
	});
};
