Closed sharbel-clearfood closed 10 years ago
Can you show the actual markup you are using in the template, with ~getCountByEntityType()
? I assume you mean you are writing ~getCountByEntityType([...])
- so you are wanting to pass in an array literal. Is that right?
In fact you can pass an array or an object to a helper, but you cannot use javascript literals, [...]
or {...}
.
The array you pass must come from data or from another helper.
For example, all of the following are possible
{{:~getArrayLength(myArrayData)}}
{{:~getArrayLength(aaa.bbb.someArray)}}
{{:~getArrayLength(~myArrayHelper)}}
{{:~getArrayLength(~myHelpers.someArray)}}
{{:~getArrayLength(~myHelperThatReturnsAnArray())}}
For the issue about passing in literals, see https://github.com/BorisMoore/jsrender/issues/195.
Closing this, as duplicate of #195 (since I didn't hear back from @sharbel-clearfood. )
Trying to pass an array to a custom helper function resulted in the error below. This happened in jsviews.js v1.0.0-alpha single-file version:
informal pre V1.0 commit counter: 55 (Beta Candidate)
Uncaught JsViews Error: Syntax error ~getCountByEntityType([12, 4],#data.entitystatistics) jsviews.js:1020error jsviews.js:1020syntaxError jsviews.js:1026parseTokens jsviews.js:1300parseParams jsviews.js:1321parseTag jsviews.js:1088tmplFn jsviews.js:1157compileTmpl jsviews.js:775tmplOrMarkupFromStr jsviews.js:725compileTmpl jsviews.js:738theStore jsviews.js:849(anonymous function)