diff --git a/helpers.js b/helpers.js index ef81893..ecb3127 100644 --- a/helpers.js +++ b/helpers.js @@ -4,7 +4,6 @@ exports.addHelper = (name, fun) => { this.helpers[name] = fun } -this.addHelper('ellipsis', (e) => { - let words = arg1.split(' ').slice(0, 10).join(' ') - return `${words} ...` +this.addHelper('ellipsis', (string, words = 10) => { + return `${string.split(' ').slice(0, words).join(' ')}...` }) diff --git a/index.js b/index.js index f8ecd76..7b73db8 100644 --- a/index.js +++ b/index.js @@ -78,8 +78,10 @@ exports.compile = (template, input) => { template = template.replace(tag.tag, getValue(tag.tag.substring(2, tag.tag.length-2))) } else { const funct = split[0].substring(2) - const val = split[1].substring(0,split[1].length-2) - template = template.replace(tag.tag, this.helpers.helpers[funct](getValue(val))) + const val1 = split.length == 2 ? split[1].substring(0,split[1].length-2) : split[1] + const val2 = split.length == 3 ? split[2].substring(0,split[2].length-2) : null + template = val2 ? template.replace(tag.tag, this.helpers.helpers[funct](getValue(val1), val2)) : + template.replace(tag.tag, this.helpers.helpers[funct](getValue(val1))) } break case 'HTML':