shdwcat / YUI

YUI - A UI system for GMS2

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Implement proper lexical scoping for templates

shdwcat opened this issue · comments

commented

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.