iFrame to execute parsed JavaScript? #100
Replies: 7 comments 8 replies
-
Getting there. 😃 I'll confirm that I am treating the React site as an exemplar of what site like these should look like. Potentially multiple code editors on a page, each with associated result areas. And, yes, clearly all of the building blocks are now in place. The current speed bump is that the Ruby2JS site uses layouts and Turbo. The layouts control the head section and Turbo works by replacing the So the challenge is to do all of this with no Unsurprisingly, Stimulus solves this problem. We can define a few core Controllers for things like a RubyEditor, a JavaScript (readonly) editor, and a Result area. The form on the demo page that lets you adjust ESLevel, Filters, and Options would also need to be a controller, even if it is only used once on the site, but that's OK. Once these controllers are in place, they would be available to all pages on the site. To use them, one would not need to write any scripts, instead one would write add a Some closing thoughts:
P.S. If you can't tell, I'm having a blast, learning new things and applying them. |
Beta Was this translation helpful? Give feedback.
-
The scripts are going to look strange for the next few days, but should continue to work as I restructure things. I'm starting by pulling all of the code which will eventually be placed into controllers into a single file, leaving the opal generated code to focus on a single purpose: exposing Along the way, I've opened bridgetownrb/bridgetown#246 |
Beta Was this translation helpful? Give feedback.
-
The example on the front page will now execute as you make changes. |
Beta Was this translation helpful? Give feedback.
-
FYI, both the homepage and demo page are breaking in Safari with a JS error message. Hard to tell what's going on due to the one-line file.
|
Beta Was this translation helpful? Give feedback.
-
The React examples are now live: https://www.ruby2js.com/examples/react/ It will take more work to get the Stimulus examples live, imports, registration, etc. |
Beta Was this translation helpful? Give feedback.
-
stimulus examples are now live. Fun fact: if you bring up a stimulus example in Safari and click on the JavaScript tab and then do the same in Chrome, Firefox, or Microsoft Edge, you will see different JavaScript. If you look in the console window, you will see an error in Safari - that's because Safari doesn't yet support some of the latest ES features. That error is recovered from, the |
Beta Was this translation helpful? Give feedback.
-
@rubys FYI, Bridgetown v0.20 is out now with better Webpack manifest support (aka multiple entry points and other arbitrary files via the |
Beta Was this translation helpful? Give feedback.
-
I was thinking, as the demo gets better and better, the final awesomeness might be to have a simple CodePen-style HTML output in an iframe that can execute the script (either automatically or via a "Run" button).
I threw a wad of code together to experiment with creating an iFrame and injecting it with code…should prove pretty simple to integrate something like that into the demo UI. Obviously the "injectscript" below would be the output from Ruby2JS' parser.
Beta Was this translation helpful? Give feedback.
All reactions