-
Notifications
You must be signed in to change notification settings - Fork 421
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
can.view Breaking backward compatibility in v2.0.5 amd #717
Comments
Does it work if your template ends with .mustache ? Sent from my iPhone
|
Let me try that, but it seems to only be an issue in AMD. |
What happens if you just use $(element).html(can.view("comp/home/home.html", {})); This could have been introduced because of #647 |
.mustache didn't work, it's still a fragment instead of a string as it is in 2.0.4. daffl: that works, but is really strange, require.toUrl just changes the path to "scripts/app/components/home/home.html"
which shows template is a string variable containing: "scripts/app/components/home/home.mustache" This fails too:
|
in line 652 of view.js, using the above syntax, |
I built an example that works. <html>
<body>
<div id='element'></div>
<script src="require.js"></script>
<script>
require(['can','jquery'], function(can, $){
$('#element').html(can.view("home.html", {}));
$('body').append(can.view.mustache("Hello")({ session: {} }));
});
</script>
</body>
</html> |
Changing it to: var str = "home.html"
$('#element').html(can.view(str, {})); works too |
wait a minute... |
no, even removing that isn't helping, but I do think this is Component related, most of the Components are loading when stepping through. |
@steeleprice ping me on skype / ghangout if you get your code to a minimal breaking case. I was just about to update the site to show 2.0.5. But I want to hold off if it's breaking. |
I'm working on a fiddle to emulate it. |
ok, so it appears that views don't work quite the same as they used to, but only inside of a component. I am OK with this since all it required was directly calling mustache.
it doesn't in 2.0.5.
I still have this error being thrown with the following line though and I am trying to track down exactly what is causing it, this line did in fact render correctly in 2.0.4.
This seems to be a tightening of what is accepted for rendering which is mostly a good thing. |
@steeleprice I'm not sure you are correct. The following works for me: <html>
<body>
<div id='element'></div>
<script src="require.js"></script>
<script>
require(['can','jquery'], function(can, $){
var str = "home.html"
$('#element').html(can.view(require.toUrl("home.html"), {}));
$('body').append(can.view.mustache("Hello")({ session: {} }));
});
</script>
</body>
</html> Please reach out to me so I can stop worrying about this and make 2.0.5 official. |
Wait ... why would you do: $(element).html(can.view(require.toUrl("comp/home/home.html"), {})); inside a component? This seems like a mistake. You should not be rendering things inside a component. |
Btw, I am writing an article about how we are going to be backwards compatible / use semantic versioning: https://gist.github.com/justinbmeyer/8812069 So if there is a breaking issue, I want to fix it ASAP so I'm not undermining the entire article :-) |
this is definitely a combination problem of Require and setting Component templates. as for rendering in the component, normally, yes, this is not done, I have to put login, logout and location finders in the body so they don't get clobbered when the hash changes and replaces content inside the There is really no perfect way to do something like this, it's going to be a trade-off somewhere.
then I have to reference app.scope.session from inside the other 3 components which now tightly couples them to an app component. If I want
inside the template. This is where Documentation of sample architectures for real-world apps is going to be enormously beneficial. We are guessing at best-practices right now using "Todos" as a template when we need to think of things outside that, like security, session observes, communication pipelines between components without a facade or sandbox (pub/sub), etc. |
Ok, I tracked this down to this pull request: As supporting @stevenvachon and @daffl I think this is still not documented, anyway we can add this to |
Don't you mean correct syntax for 2.0.5 is: template: can.view(require.toUrl("comp/home/home.html")), Sorry about the break. We are trying very hard to prevent that. |
No, this is a GOOD change and just needs to have some documentation to close this issue.
|
So #718 adds documentation for this. If anybody thinks it is inadequate please reopen this issue. |
There is only one other odd thing I noticed in this issue, but its not really the same issue and would also be solved with documentation. self closing tags have unexpected behavior in most browsers. |
I am having a major issue with v2.0.5.
I have a working App that has had no other change except a straight replacement of v2.0.4 with v2.0.5 AMD.
These statements used to work:
Now they both fail in scanner.js at line 249 with Object doesn't support property or method 'replace'
This is because source is a document fragment.
I can get around the first by first saving the view to a variable then setting html to the frag, but this seems weird to have to do when I never had to previously.
The second sample is even used in all the documentation for Components.
Am I missing something that documents this and need to change my syntax?
I'd consider this a pretty big deal since I would have to change at least dozens of places views are loaded.
Thanks
The text was updated successfully, but these errors were encountered: