diff --git a/lib/wt2html/tt/TemplateHandler.js b/lib/wt2html/tt/TemplateHandler.js index 2ba19899d..ed0794344 100644 --- a/lib/wt2html/tt/TemplateHandler.js +++ b/lib/wt2html/tt/TemplateHandler.js @@ -481,13 +481,19 @@ TemplateHandler.prototype.resolveTemplateTarget = function(state, targetToks) { // Strip ":" after skipping empty tokens, if any if (isPF) { while (firstTok === '') { - firstTok = targetToks[0]; // FIXME: Isn't guaranteed to be a string + firstTok = targetToks[0]; targetToks = targetToks.slice(1); } - console.assert(firstTok[0] === ':', 'Expecting : in parser function definiton'); - firstTok = firstTok.slice(1); + if (typeof firstTok === 'string') { + console.assert(firstTok[0] === ':', 'Expecting : in parser function definiton'); + pfArgToks = [firstTok.slice(1)].concat(targetToks); + } else { + // FIXME: Again, protect from crashers. See below. + pfArgToks = targetToks; + } + } else { + pfArgToks = [firstTok].concat(targetToks); } - pfArgToks = [firstTok].concat(targetToks); } else { // FIXME: In the scenario where the target itself is not a string, // protect from crashers by using the full token -- this is still