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

Add support for in-place scripting via reactive script tag. #12

Open
Tal500 opened this issue Sep 5, 2021 · 0 comments
Open

Add support for in-place scripting via reactive script tag. #12

Tal500 opened this issue Sep 5, 2021 · 0 comments

Comments

@Tal500
Copy link
Owner

Tal500 commented Sep 5, 2021

We need to support in-place scripting, meaning to support the user to put a script anywhere he wants (in the reactive block context of course).

As reactive element tag, we should have two options (which are identical):

  • {% #script %}js_script_with_reactivity{% /script %}
  • {%#%}<script>js_script_with_reactivity</script>{%#%} - This option is also more friendly to HTML IDEs.

The script is always executed after after (re)rendering event(i.e. in post_calc_script), and in the js environment of the current reactive context.

The script may also define JS definitions, and will be visible to all scripts which is defined after the script and under the same context.

The script should have a way to attach destructor javascript functions, which will be executed when the reactive context gets destructed(i.e. in destructor script of the context).

After doing so, we may allow in-place events registering in reactive HTML element tags, via on***={{js_script}}(legacy DOM event registration) or on:***={{js_script}}(modern DOM event registration, similar to svelte).
The implementation will register them (when using the expression {{...}} indicate JS script) inside JS script and not in the printed HTML tag, since they might(and should!) reference JS code in their current JS context(which is related to the current reactive context, as discussed earlier).

This way we may and need to change the main example code and put the script inside tags and inside for loops iterations.

After doing all this, we can and need to put all reactive definitions and variables encapsulated inside a self invoked function, in a single and long HTML script tag.

Tal500 added a commit that referenced this issue Sep 29, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant