mirror of
https://github.com/JuanCanham/HackMyResume.git
synced 2025-05-04 13:27:07 +01:00
Add basic multiplexing support.
This commit is contained in:
@ -10,27 +10,37 @@ Underscore template generate for FluentCV.
|
||||
module.exports = function( json, jst, format, cssInfo, opts ) {
|
||||
|
||||
// Tweak underscore's default template delimeters
|
||||
_.templateSettings = opts.template;
|
||||
var delims = opts.themeObj.delimeters || opts.template;
|
||||
if( opts.themeObj.delimeters ) {
|
||||
delims = _.mapObject( delims, function(val,key) {
|
||||
return new RegExp( val, "ig")
|
||||
});
|
||||
}
|
||||
_.templateSettings = delims;
|
||||
|
||||
// Convert {{ someVar }} to {% print(filt.out(someVar) %}
|
||||
// Convert {{ someVar|someFilter }} to {% print(filt.someFilter(someVar) %}
|
||||
jst = jst.replace( _.templateSettings.interpolate, function replace(m, p1) {
|
||||
jst = jst.replace( delims.interpolate, function replace(m, p1) {
|
||||
if( p1.indexOf('|') > -1 ) {
|
||||
var terms = p1.split('|');
|
||||
return '{% print( filt.' + terms[1] + '( ' + terms[0] + ' )) %}';
|
||||
return '[~ print( filt.' + terms[1] + '( ' + terms[0] + ' )) ]]';
|
||||
}
|
||||
else {
|
||||
return '{% print( filt.out(' + p1 + ') ) %}';
|
||||
return '[~ print( filt.out(' + p1 + ') ) ]]';
|
||||
}
|
||||
});
|
||||
|
||||
// Strip {# comments #}
|
||||
jst = jst.replace( _.templateSettings.comment, '');
|
||||
|
||||
jst = jst.replace( delims.comment, '');
|
||||
// Compile and run the template. TODO: avoid unnecessary recompiles.
|
||||
jst = _.template(jst)({ r: json, filt: opts.filters, cssInfo: cssInfo, headFragment: opts.headFragment || '' });
|
||||
|
||||
return jst;
|
||||
var compiled = _.template(jst);
|
||||
var ret = compiled({
|
||||
r: json,
|
||||
filt: opts.filters,
|
||||
cssInfo: cssInfo,
|
||||
headFragment: opts.headFragment || ''
|
||||
});
|
||||
return ret;
|
||||
|
||||
};
|
||||
|
||||
|
Reference in New Issue
Block a user