active-css icon indicating copy to clipboard operation
active-css copied to clipboard

Add a syntax to fetch a variable based on a string name

Open bob2517 opened this issue 3 years ago • 4 comments

Currently variables written directly in HTML looks like this: {$varname}. A need has arisen for there to be an additional syntax for fetching a variable based on a string name. An old programming term for that is "variable substitution".

Something like {${$varnameString}} and {${"varname"}}.

The inner parentheses, or whatever it ends up being, would be needed in case this was needed: {${$obj.varName}}.

This would then spill over into the syntax for if statements, etc., and look like ${$varnameString} and ${"varname"}.

It would also need to work like that in run command JS blocks and {= =} JS expressions.

bob2517 avatar Sep 22 '22 17:09 bob2517

Needs to work like lodash _get() and handle complex paths, like the new getVar() helper function.

bob2517 avatar Oct 06 '22 18:10 bob2517

On review this has come up several times in development scenarios, so worth doing.

bob2517 avatar Jan 21 '24 11:01 bob2517

Note to self: There is a helper function in the docs called getVar for use in JS expressions which gets a variable value based on a path. The new syntax would be a native ACSS equivalent for use in non JS commands.

bob2517 avatar Jan 21 '24 11:01 bob2517

Do this for attribute references too, as in https://github.com/Active-CSS/active-css/issues/304

bob2517 avatar Jan 21 '24 12:01 bob2517