canjs/can-compile

CanJS 2.1 Compatibility

marshallswain opened this issue · 5 comments

View output for CanJS 2.0 uses the Scanner.hookupTag() method, which has been removed from can/view/scanner.js in CanJS 2.1. Is can.view.tag the replacement? I notice that it has a different API.

Good question. I haven't looked into a 2.1 upgrade yet. Seeing as it will be released soon I should probably look into it. One feature planned for 2.1 is DOM-less compilation which will probably change a couple of things for can-compile anyway.

Just in case others come looking for answers on how to get this to work...

Now that CanJS 2.1 has been released, this will no longer work without passing in a CanJS version number in the options:

var options = {
  src: ['client/app-main/**/*.mustache'],
  out: 'public/assets/main.views.js',
  tags: ['editor', 'my-component'],
  version: '2.0.7'
};

Regarding what I asked about can.view.Scanner in the first comment in this thread, after compiling with 2.1 and comparing the old file with the new, can.view.Scanner.hookupTag() is being replaced with can.view.pending()

I tried to work on this a bit more today. If you leave tags out of options, it actually finishes compiling using 2.1:

var options = {
  src: ['client/app-main/**/*.mustache'],
  out: 'public/assets/main.views.js'
};

Unfortunately the components don't work initialize on their elements. I'm not sure what purpose options.tags served, as all of my can.Components were able to work properly using 2.0.7 without being listed in options.tags.

I'm not sure what's making it so that the Components don't bind to their element. Maybe options.tags is required again? Looking at compile.js, can.view.Scanner.tags is gone from 2.1. I thought that maybe it moved to can.view.callbacks._tags:

if (options.tags && options.tags.length) {
  for (var i = 0; i < options.tags.length; i++) {
    console.log(options.tags[i]);
    // can.view.Scanner.tags[options.tags[i]] = noop;
    can.view.callbacks._tags[options.tags[i]] = noop;
  }
}

But it didn't work. I'm not even sure what can.view.callbacks is for just yet. I don't have enough knowledge of the internals of CanJS to make this a very smooth effort on my part, but I'm trying to contribute as I get time.

It looks like the code for domless compilation was removed from 2.1, so I figured I would try to get it working the way it has been: canjs/canjs@b8ee2ed

taai commented

Also needs to support stache templates! And EJS is deprecated in version 2.1.

Closed via #23