- Notifications
You must be signed in to change notification settings - Fork37
-
ruby2js supports filters for react and vue (v3 not yet ready, seems much more complicated than v2) and ... recently i got in touch with svelte.dev it doesn't use the virtual DOM (like react etc.) but compiles/transepiles into vanilla JS (manipulating DOM directly, but only when needed) making components really reusable. also the notation is much more intuitive than using react/vue etc. i think it would be awesome to have some kind of support for svelte.dev in ruby2js ( what do you think about a possible svelte.dev and ruby2js coupling ... |
BetaWas this translation helpful?Give feedback.
All reactions
Replies: 4 comments 4 replies
-
Technically, svelte (and, for that matter, Vue 3) are supersets of HTML, not JS. This means either one of three things:
I would suggest focusing on the first option initially, and then perhaps proceeding to either the second or the third option. I don't have enough (or for that matter any) svelte experience to design a reasonable mapping of svelte to Ruby, but if somebody could develop a set of specs (and by all that I mean a list of "this input should produce that output"), I can help with the implementation. |
BetaWas this translation helpful?Give feedback.
All reactions
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
-
i'm not a svelte expert (yet) but as far as i understand it a transformation of to would be enough transformations of conditional/loop svelte blocks (outside of <script> ...</script> could be omitted in the first version (or even at all) but i'm really not sure if it would be all ... |
BetaWas this translation helpful?Give feedback.
All reactions
-
I'm not sure where/how this would fit into the existing project, but to keep the discussion going, here is a script that will convert source that contains require'nokogiri'require'ruby2js'ifARGV.length ==0source=STDIN.readelsesource=ARGV.map{|file|IO.readfile}.joinendfragment=Nokogiri::HTML5.fragment(source)fragment.search('script[lang=ruby]').eachdo |script|script.remove_attribute'lang'script.content=Ruby2JS.convert(script.content).to_sendputsfragment.to_html |
BetaWas this translation helpful?Give feedback.
All reactions
-
the problem is not the html stuff (can be solved as in your solution), but the such a construct should be build into ruby2js (with a better name :-) |
BetaWas this translation helpful?Give feedback.
All reactions
-
The original But seriously, I wonder if block syntax even makes sense. For example, this is valid Svelte code: It's almost like a decorator, which doesn't immediately map to regular Ruby syntax. But I'll give it a bit of thought… |
BetaWas this translation helpful?Give feedback.
All reactions
-
So this is valid Ruby syntax: $:ifcount >=10alert("count is dangerously high!")count=9end$:doubled=count *3 Normally |
BetaWas this translation helpful?Give feedback.
All reactions
-
First, I will confirm that Next, I will note that for Jared's latest suggestion to parse correctly, the Trying to think outside of the box:
|
BetaWas this translation helpful?Give feedback.
All reactions
-
Why not just convert ruby symbol (:id) into svelte's $:id? There's anyway no direct equivalent of ruby's symbol in js. |
BetaWas this translation helpful?Give feedback.