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

POC: JavaScript expressions in brick args #9510

Closed
wants to merge 1 commit into from

Conversation

twschiller
Copy link
Contributor

@twschiller twschiller commented Nov 12, 2024

What does this PR do?

  • Quick POC to evaluate gaps for supporting writing JavaScript directly
    • Goal: evaluate the feasibility of eliminating need to users have to learn Nunjucks text template syntax
  • Implements:
    • Add javascript expression type
    • Javascript toggle mode
    • Javascript renderer using existing Sandbox
    • Javascript expression analysis

Gaps

  • I didn't update the snapshot test
  • Variable dereference character @ is not valid in JS identifiers. (It's also a bad character because @ toggles username popups in many collaboration tools)
    • A quick way to roll out to advanced users would be to make the variables accessible via a $vars object, e.g., $vars["@input.url"].length
    • We could write a custom lexer to transform @<ident> to $vars["<ident>"] automatically. That's what val.town used to do (IIRC, they used a custom babel plugin to do that). They then moved to vanilla JS syntax to better benefit from the JS tooling ecosystem
  • Would need a JS tokenizer, e.g., https://github.com/lydell/js-tokens for variable popover

Demo

image

image

For more information on our expectations for the PR process, see the
code review principles doc

@twschiller twschiller self-assigned this Nov 12, 2024
@twschiller twschiller added the do not merge Merging of this PR is blocked by another one label Nov 12, 2024
Copy link

Playwright test results

passed  154 passed
skipped  2 skipped

Details

report  Open report ↗︎
stats  156 tests across 51 suites
duration  11 minutes, 43 seconds
commit  5a78226
info  For more information on how to debug and view this report, see our readme

Skipped tests

chrome › tests/runtime/googleSheetsIntegration.spec.ts › can activate a google spreadsheet mod with config options
msedge › tests/runtime/googleSheetsIntegration.spec.ts › can activate a google spreadsheet mod with config options

@twschiller twschiller changed the title POC: JavaScript expressions POC: JavaScript expressions in brick args Nov 12, 2024
@twschiller twschiller closed this Nov 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
do not merge Merging of this PR is blocked by another one
Development

Successfully merging this pull request may close these issues.

1 participant