glimmer-dsl-web
glimmer-dsl-web copied to clipboard
[Idea] Draw from existing HTML code and HTML (.html) files
Hey there Andy,
This is just a semi-random idea.
In the README you show this example:
<div id="application"></div>
And the corresponding glimmer code:
require 'glimmer-dsl-web'
include Glimmer
div('#application') {
label(class: 'greeting') {
'Hello, World!'
}
}
What if the HTML code would already exist, and glimmer would parse that code (as a String), and then automatically create / build the corresponding glimmer code? Optionally to also output this and allow people to re-use it as-is.
This could allow for the functionality to, for instance, download a .html file, and have glimmer parse it into "glimmer elements" so to speak.
It could also allow to work with "glimmer components" and re-use them easily.
I guess you may ask "what is the use case and rationale for this"?
Well, it would allow for a bit more flexibility in using of the glimmer suite, which may be useful. It may also make a transition into glimmer easier. And people could embed and mix HTML code with "glimmer code".
Now that may be a bit messy (PHP code serves as negative example perhaps), but ultimately the flexibility gain may be useful, so that may be a trade off simply.
An additional idea could be to actually write purely in HTML and CSS and then just build glimmer apps "for free", without having to learn or transition into the glimmer DSL (which may take a while for people to learn; not everyone may want to learn ruby either, for instance).
Anyway, this is just an idea. Please feel free to proceed as always in any way you see fit. :)
PS: Actually, as a "spin off" idea to this, if glimmer were to be able to parse HTML/CSS, and if it were to obtain a full (and flexible) specification, people could actually tap into it and have glimmer act as the "translator" between different toolkits AND DSLs, even across different programming languages. And then perhaps become a bit more like rack (a ground for others to build upon) and perhaps also rubocop (e. g. having code elements that can yield glimmer code, or other code, automatically, such as via the autocorrect option for rubocop, kind of like a "glimmer AI", aka "Hello Sir, today I shall take your HTML/CSS/JavaScript code and automatically translate it into ruby + glimmre for you - and then also automatically compile a statically compiled variant via graalVM". Ok a bit of wishful thinking here, but it's just an idea after all.