These are chat archives for canjs/canjs

May 2017
May 24 2017 10:11 UTC

Hi guys, could you pls help with one question:

On our project we would like to test viewModel using QUnit library, we tried to use testee as a runner for tests but it requires a browser (phantomjs as default). So question is what is the best approach for testing viewModel of component only in cmd?

Pedro Mendes
May 24 2017 13:38 UTC
@kaderiho If possible, try to use Chrome headless which recently became available in Chrome 59. Quoting "It brings all modern web platform features provided by Chromium and the Blink rendering engine to the command line".I didn't test yet, though.. Regarding PhantomJS the following news could interest you - Stepping down as maintainer
Viktor Busko
May 24 2017 17:30 UTC

Guys, I have such helper:

can.stache.registerHelper('i18n', function (prop, options) {
    var rawProp =;
    var wildcardKeys = Object.keys(options.hash);
    var replacedString;

    if (wildcardKeys.length === 0) {
        return rawProp;

    replacedString = rawProp.replace(/{(\w+)}/g, function (array, key) {
        return options.hash[key].isComputed ? options.hash[key]() : options.hash[key];

    return replacedString;

and use it like:

{{i18n 'text_with_variable' 0='variable'}}

this works fine in 2.2.9, but as soon as I update to latest 2nd Can, this syntax returns me 0 as options value instead of options object.
As result it fails when try to do Object.keys(options.hash), because options.hash - undefined
This syntax was deprecated ? I just looking through docs and this should be working, but it seems that it was changed.

As I got I must write this (and change helper a bit) in order to fix this:
{{i18n prop='text_with_variable' 0='variable'}}
Viktor Busko
May 24 2017 17:46 UTC
But in this case it ignores hash elements except prop, so if I have prop='my_text' 0='text' 1='text2' in options.hash I have only prop
Brad Momberger
May 24 2017 18:46 UTC
@Lighttree I can't seem to replicate that issue with 2.3.31. Here's a JSBin showing it working as expected:,js,console,output
Ah wait, I think I see. With can-stache on 2.3 branch there's an issue. It works fine with can.Mustache
Brad Momberger
May 24 2017 18:52 UTC
Interestingly it looks like it's still an issue in stache up through CanJS 3.8.1 -- a bug report is in order for this.
Yeswanth Raghav T
May 24 2017 18:53 UTC
I need help on Find all function of a Model
I am able to assign a array of models to a attribute of a model using model.List
How can i assign a single value (not in an array) to a attribute of model
I am new to can JS
Please Help
Brad Momberger
May 24 2017 19:02 UTC
@Lighttree filed as canjs/can-stache#203 -- until then you can use can.Mustache instead of can.stache, use only non-numeric hash keys as a workaround, or use positional parameters when you need numbers and process your params like this:
can.stache.registerHelper("i18n", function(prop) {
  var args = [], 1);
 var rawProp =;
  var options = args.pop();
  var wildcards = $.extend({}, options.hash, args);
@tyraghav can you show us some code examples for what you're doing with model.List and what you think should happen for one single value?
Yeswanth Raghav T
May 24 2017 19:20 UTC
I am displaying details of person from the response json from a java function call
I am able to parse the json if it is like this
output : {
response : { [
Name : tyraghav,
Sorry for incomplete message
Will send you the details shortly
Ivo Pinheiro
May 24 2017 23:08 UTC

Is there any way to configure can-connect to cache results, in order to when the same request happens again, instead of making a new request to the service, returns the cached result.

I've made some changes on the TODO example, adding a button "show/hide" in order to insert/remove the "todo-list" component on the page:,js,console,output

What I've noticed is that the request is always being made to the service (checking logs) even if the query parameters are the same.

superMap uses a fall-through-cache and localstorage-cache, which means it will first respond with the data from localStorage, but will then make a request to update the data in case it has changed on the server