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. |
Beta Was this translation helpful? Give feedback.
-
|
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 ... |
Beta Was this translation helpful? Give feedback.
-
|
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'
if ARGV.length == 0
source = STDIN.read
else
source = ARGV.map {|file| IO.read file}.join
end
fragment = Nokogiri::HTML5.fragment(source)
fragment.search('script[lang=ruby]').each do |script|
script.remove_attribute 'lang'
script.content = Ruby2JS.convert(script.content).to_s
end
puts fragment.to_html |
Beta Was this translation helpful? Give feedback.
-
|
Why not just convert ruby symbol (:id) into svelte's $:id? There's anyway no direct equivalent of ruby's symbol in js. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
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 (
maybe it could also be build into serbea.dev/bridgetownrb.com) ???
what do you think about a possible svelte.dev and ruby2js coupling ...
Beta Was this translation helpful? Give feedback.
All reactions