Skip to content
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

template call scopes, template static scopes, passed scope ... oh my!!! #281

Open
justinbmeyer opened this issue Jul 12, 2018 · 0 comments

Comments

@justinbmeyer
Copy link
Contributor

justinbmeyer commented Jul 12, 2018

So there's a weirdness in can-stache and can-component that would be good to figure out.

This is easiest to understand with an example:

<outer><inner>{{HERE}}</inner></outer>

With leak scope, this should be something like:

[
  <outer> TEMPLATE,
  <outer> VM,
  <inner> TEMPLATE,
  <inner> VM
]

In an ideal world, can-component could fashion this itself and do something like:

passedOuterScope.add( new Template({ ... }) ).add( new VM() )

But the problem is that only can-stache has to add the filename, inlinePartials and view.

I think the solution is to keep this information in two different types. For now, I'll call them:

  • TemplateFrame - Something that houses variables/partials/etc for a "call" of a template. I used Frame because it's like an ActivationFrame in the stack.
  • TemplateData - This houses static information for a template.

can-component would do:

passedOuterScope.add( new TemplateFrame({ ... }) ).add( new VM() )

and can-stache would always do:

var templateData= {filename: "..."};

renderer = function(scope, nodeList){
  scope = scope.add( new TemplateData( templateData ) )
  return render(scope, nodeList)
}

Ideally these should be renamed with how they work in can-view-scope. There's probably only the TemplateContext. But this should really be something like ScopeAndHelperValues

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant