-
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
confusing example for can.Control template data passing #713
Comments
👍 By all accounts, I have always done It's a few more lines of code, but less confusing with can.view documentation as supplemental. |
|
I am curious if this plugin is being included by default again.. My project is allowing this syntax without explicitly pulling the plugin (we just steal can/util/jquery) |
When you steal "can", you get what's in can/can.js: steal('can/util', 'can/control/route', 'can/model',
'can/view/mustache', 'can/component', function(can) {
return can;
}); So most likely something in your app is stealing the modifiers plugin. |
#713 cleanup can.Control, fixup contributing guide
Closed via #746 |
In the documentation for can.Control, we use sugary syntax to render the template, ie
self.element.html('todos.ejs', new Todo.List({}) )
andself.element.html( self.options.view, todos )
.While this is more terse, it is confusing for beginners to the framework. For one, it appears we are passing a data object to what is (in most cases)
$().html()
, which would indicate we have changed the API to this library method. Secondly, it is hard to understand that the data object is being provided to the template viacan.view
, not to the HTML rendering method.I propose we modify these examples to show the template passing through can.view, and add an additional syntax guide for templates used in a steal context. This would result in the following modifications of the above items
self.element.html( can.view( 'todos.ejs', new Todo.List([]) )
self element.html( can.view( self.options.template, todos) )
for steal, we should show a steal wrapper pulling a .mustache file, and resulting in 'template' being passed, ie
We can provide an example of the shortened syntax as well, but as an optimization rather than the default example.
The text was updated successfully, but these errors were encountered: