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

Proposal: Support for tagged template literals and bindings. #5461

Open
4 tasks
frank-dspeed opened this issue Jan 24, 2020 · 0 comments
Open
4 tasks

Proposal: Support for tagged template literals and bindings. #5461

frank-dspeed opened this issue Jan 24, 2020 · 0 comments

Comments

@frank-dspeed
Copy link
Contributor

frank-dspeed commented Jan 24, 2020

lit-html can-lit

To Implament something like can stache with lit-html or any backtick tag
we need to cheat a bit but can then reuse existing codebase!!!

What needs to be done

  • Propertys need a Name Symbol
  • Process the Template once with the Name Symbol
  • Hand over to result to can-stache.
  • optional but cool would be if can stache could add support for ${} === string as long as it returns strings?

Explaining why we need to use the symbol name way?!?

because a tagged template literal is a function that accepts unlimited arguments and we don't know the name of the arguments but we know the arguments, so the arguments need to get converted to its property expression via symbols, then we return the argument expression for stache and can process it.

it needs to be aware of the local scope tree.

a raw example of the algo that uses a cheat as it knows scope name

// Note this works as long as we deal with a single object as parameter for the template function
function myTemplate(scope) {
// we need now to look in the Lit function
return Lit`my deep  ${scope.person.name}`
}

const lit = (..args) => {
  const literals = args[0]
  // now we iterate over args[1.........Infinity]
  // and need to know scope.person.name
  return 'my deep  {{scope.person.name}}'
}
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