1
0
mirror of https://github.com/JuanCanham/HackMyResume.git synced 2024-11-22 16:30:11 +00:00

Introduce new helpers.

This commit is contained in:
hacksalot 2015-12-19 00:24:21 -05:00
parent 7daba910ed
commit ade60022fd

View File

@ -37,12 +37,41 @@ Template helper definitions for Handlebars.
return txt; return txt;
}); });
// Set up a last-word helper so we can do:
// {{lastWord val [true|false]}}
HANDLEBARS.registerHelper("link", function( text, url ) {
return url && url.trim() ?
('<a href="' + url + '">' + text + '</a>') : text;
});
// Set up a last-word helper so we can do: // Set up a last-word helper so we can do:
// {{lastWord val [true|false]}} // {{lastWord val [true|false]}}
HANDLEBARS.registerHelper("lastWord", function( txt ) { HANDLEBARS.registerHelper("lastWord", function( txt ) {
return txt && txt.trim() ? _.last( txt.split(' ') ) : ''; return txt && txt.trim() ? _.last( txt.split(' ') ) : '';
}); });
// Set up a skill colorizing helper:
// {{skillColor val}}
HANDLEBARS.registerHelper("skillColor", function( lvl ) {
switch(lvl) {
case 'beginner': return '#5CB85C';
case 'intermediate': return '#F1C40F';
case 'advanced': return '#428BCA';
case 'master': return '#C00000';
}
});
// Set up a skill colorizing helper:
// {{skillColor val}}
HANDLEBARS.registerHelper("skillHeight", function( lvl ) {
switch(lvl) {
case 'beginner': return '30';
case 'intermediate': return '16';
case 'advanced': return '8';
case 'master': return '0';
}
});
// Set up a Markdown-to-WordProcessingML helper so we can do: // Set up a Markdown-to-WordProcessingML helper so we can do:
// {{initialWords val [true|false]}} // {{initialWords val [true|false]}}
HANDLEBARS.registerHelper("initialWords", function( txt ) { HANDLEBARS.registerHelper("initialWords", function( txt ) {
@ -55,6 +84,12 @@ Template helper definitions for Handlebars.
return url && url.trim() ? url.trim().replace(/^https?:\/\//i, '') : ''; return url && url.trim() ? url.trim().replace(/^https?:\/\//i, '') : '';
}); });
// Set up a URL-trimming helper to drop the protocol so we can do:
// {{trimURL url}}
HANDLEBARS.registerHelper("toLower", function( txt ) {
return txt && txt.trim() ? txt.toLowerCase() : '';
});
// Set up a Markdown-to-WordProcessingML helper so we can do: // Set up a Markdown-to-WordProcessingML helper so we can do:
// {{either A B}} // {{either A B}}
HANDLEBARS.registerHelper("either", function( lhs, rhs, options ) { HANDLEBARS.registerHelper("either", function( lhs, rhs, options ) {