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
42 stars 7 forks source link

New {JSON} special variable #203

Closed bob2517 closed 2 years ago

bob2517 commented 2 years ago

When JSON is retrieved from the server, currently the variables that are present with the JSON string are automatically converted.

However, if you want to reference these in a loop, and the JSON variables don't have a parent variable, it's not very handy because there is nothing to iterate over.

So there is now a {JSON} variable available on the 2.9.0 branch, which contains the latest JSON variables retrieved from an ajax call. This {JSON} variable can be iterated over. It can also work with it's sub-variables as reactive variables, ie. {{JSON.myChangingVar}}. It's limited to the scope of the component it is used in, or the document itself.

An earlier version in 2.9.0 was {$JSON}, but those $ variables are better suited for HTML content rather than JSON, and things weren't working as expected, so I've now removed the $ and everything seems ok now.

A note on variable re-assignment. Variable reassignment on an object only re-assigns by reference, which isn't very intuitive. The whole default point of reassigning should be to get rid of dependency on an existing variable. So at some point I need to put in a clone feature which clones an object at point of reassignment. It may need a new var-clone command, or something like that. I'm not putting it in as default, as reassigning to object reference is the default method for JS.

dragontheory commented 2 years ago

An earlier version in 2.9.0 was {$JSON}, but those $ variables are better suited for HTML content rather than JSON, and things weren't working as expected, so I've now removed the $ and everything seems ok now.

Updated my example to reflect this change. Seems to be working as described. https://codepen.io/dragontheory/pen/zYEBoEK?editors=1100

bob2517 commented 2 years ago

Closing in preparation for release.

bob2517 commented 2 years ago

An earlier version in 2.9.0 was {$JSON}, but those $ variables are better suited for HTML content rather than JSON, and things weren't working as expected, so I've now removed the $ and everything seems ok now.

Updated my example to reflect this change. Seems to be working as described. https://codepen.io/dragontheory/pen/zYEBoEK?editors=1100

Groovy