Active-CSS / active-css

The epic event-driven browser language for UI with functionality in one-liner CSS. Over 100 incredible CSS commands for DOM manipulation, ajax, reactive variables, single-page application routing, and lots more. Could CSS be the JavaScript framework of the future?
https://activecss.org
Other
43 stars 7 forks source link

Allow @if statements to parse variables that have a syntax of $var{@data-attr} #323

Closed bob2517 closed 1 year ago

bob2517 commented 1 year ago

Several times in the past year I've found a need for this, but at the time got a quick workaround to save time.

I've just done a commit on the latest branch to implement this properly for @if statements. Variable assignment can already do it.

Eg. this should now work:

$myDiv{@data-ref}: true;
@if ($myDiv{@data-ref} === true) {
}

If attribute data-ref = "A", then the attribute gets substituted into the variable name before evaluating and the variable becomes $myDivA.

I tried a blanket fix to for all variable handlings in the core, but it didn't work off the bat, so I've just left this scenario in for now, which looks like it works from the tests I've done. If anyone finds another place where this attribute substitution is needed, let me know. Meanwhile if I stumble into another place where it's needed then I'll just do the upgrade.

bob2517 commented 1 year ago

Closing pending release.