These are chat archives for canjs/canjs

25th
Jul 2015
opolyo01
@opolyo01
Jul 25 2015 01:49
Why is my helper method never getting called inside of can.Component? If I place it inside of viewModel it would be called, but I wouldn't have access to options.fn
return can.Component.extend({ tag: "date-picker", template: template, scope: ViewModel, helpers: { selected: function (dt) {
so selected wouldn't be called from stache template
opolyo01
@opolyo01
Jul 25 2015 01:55
<td class="{{#clickable}}selectable{{/clickable}} {{selected dt}} {{cls}}" {{data 'selectable'}}> <span class="label">{{selectable}}{{txt}}</span> </td>
none of helper ever getting called
opolyo01
@opolyo01
Jul 25 2015 03:18
so in console I see I am getting those -- WARN: can/view/stache/mustache_core.js: Unable to find key or helper "txt".
can.js:181 WARN: can/view/stache/mustache_core.js: Unable to find key or helper "selectable".
can.js:181 WARN: can/view/stache/mustache_core.js: Unable to find key or helper "clickable".
can.js:181 WARN: can/view/stache/mustache_core.js: Unable to find key or helper "cls".
opolyo01
@opolyo01
Jul 25 2015 03:30
is it still a bug?
bitovi/canjs#1306
opolyo01
@opolyo01
Jul 25 2015 07:21
I think I found the core of this issue

`steal(
"./date-picker.stache!",
//global
"can",

function (template, can) {
    can.Component.extend({
        tag: "date-picker",
        template: "{{modifiedName 'randomName'}}",
        scope: {},
        helpers:{
            modifiedName: function(name){
              name = typeof name === "function" ? name() : name;
              return "Custom " + name;
            }
        }
    });
}

);
`

this will work as expected and display Custom randomName
However if I load template from template file, it will never call modifiedName helper function

`steal(
"./date-picker.stache!",
//global
"can",

function (template, can) {
    can.Component.extend({
        tag: "date-picker",
        template: template,
        scope: {},
        helpers:{
            modifiedName: function(name){
              name = typeof name === "function" ? name() : name;
              return "Custom " + name;
            }
        }
    });
}

);
`