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

Implement proper lexical scoping for templates #62

Open
shdwcat opened this issue Apr 10, 2023 · 0 comments
Open

Implement proper lexical scoping for templates #62

shdwcat opened this issue Apr 10, 2023 · 0 comments
Assignees
Labels
enhancement New feature or request
Milestone

Comments

@shdwcat
Copy link
Owner

shdwcat commented Apr 10, 2023

Slot names are currently cascaded down the element tree to enable lazy evaluation of templates, however any inner template element whose slots share names with an outer template element will cause variable shadowing problems. The solution is lexical scoping of slot variables, so that e.g. $name in a template's content only refers to the name slot given by the definition.

Proposed implementation: in YuiTemplateDefinition's constructor, traverse the template content and replace any raw string value that confirms to a YUI script expression with a YuiLexicalExpr with a direct reference to the slots of the template definition. This way we don't actually have to parse the expressions ahead of time to determine if they contain slots, we can simply bind the unparsed expression string to the slot definitions for later evaluation.

@shdwcat shdwcat added the enhancement New feature or request label Apr 10, 2023
@shdwcat shdwcat added this to the 0.6.0 milestone Apr 10, 2023
@shdwcat shdwcat self-assigned this Apr 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant