glimmer-dsl-web 0.2.7 → 0.2.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/README.md +116 -11
- data/VERSION +1 -1
- data/glimmer-dsl-web.gemspec +3 -3
- data/lib/glimmer/web/element_proxy.rb +2 -1
- data/lib/glimmer-dsl-web/samples/hello/hello_content_data_binding.rb +2 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a9f4b7e33522df500ca481bf4b9ba138c6cb3dad3847bee24f3f506fa985ac11
|
4
|
+
data.tar.gz: fd7fd300d3519276ffb27de97049daf2b59cec4a5f1c2882b7386257dddc25d7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dbfcc16bf944ef8726912ee31e2ab8f045bba776a63d4377fea70c0fa28d990907b17f94b59ea0cc8e6e4855a4bba2bd965a66bea44fb53fd20ce3539cb09518
|
7
|
+
data.tar.gz: 1220943c86ee1455654901700c1bf90834b81af96e355b86ebb7a91275a6130030917ce13eaa755cd0a8388d3fb9497b57a75372f1409989b9ffe0646774df32
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,9 @@
|
|
1
1
|
# Change Log
|
2
2
|
|
3
|
+
## 0.2.8
|
4
|
+
|
5
|
+
- Support Content Data-Binding to multiple model attributes via `computed_by` option (e.g. `content(@game, :scale, computed_by: [:width, :height])` or `content(@game, computed_by: [:scale, :width, :height])` will re-render content on changes to `:scale`, `:width`, or `:height`)
|
6
|
+
|
3
7
|
## 0.2.7
|
4
8
|
|
5
9
|
- Unidirectional Data-Binding of element `style` property
|
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# [<img src="https://raw.githubusercontent.com/AndyObtiva/glimmer/master/images/glimmer-logo-hi-res.png" height=85 />](https://github.com/AndyObtiva/glimmer) Glimmer DSL for Web 0.2.
|
1
|
+
# [<img src="https://raw.githubusercontent.com/AndyObtiva/glimmer/master/images/glimmer-logo-hi-res.png" height=85 />](https://github.com/AndyObtiva/glimmer) Glimmer DSL for Web 0.2.8 (Beta)
|
2
2
|
## Ruby in the Browser Web Frontend Framework
|
3
3
|
### Finally, Ruby Developer Productivity, Happiness, and Fun in the Frontend!!!
|
4
4
|
[![Gem Version](https://badge.fury.io/rb/glimmer-dsl-web.svg)](http://badge.fury.io/rb/glimmer-dsl-web)
|
@@ -10,7 +10,7 @@
|
|
10
10
|
|
11
11
|
[![Todo MVC](/images/glimmer-dsl-web-samples-regular-todo-mvc.gif)](/lib/glimmer-dsl-web/samples/regular/todo_mvc.rb)
|
12
12
|
|
13
|
-
You can finally have Ruby developer happiness and productivity in the Frontend! No more wasting time splitting your resources across multiple languages, using badly engineered, over-engineered, or premature-optimization-obsessed JavaScript libraries, fighting JavaScript build issues (e.g. webpack), or rewriting Ruby Backend code in Frontend JavaScript. With [Ruby in the Browser](https://www.youtube.com/watch?v=4AdcfbI6A4c), you can have an exponential jump in development productivity (2x or higher), time-to-release (1/2 or less time), cost (1/2 or cheaper), and maintainability (~50% the code that is simpler and more readable) over JavaScript libraries like React, Angular, Ember, Vue, and Svelte, while being able to reuse Backend Ruby code as is in the Frontend for faster interactions when needed. Also, companies can cut their hiring budget in half by having Backend Ruby Software Engineers do Frontend Development
|
13
|
+
You can finally have Ruby developer happiness and productivity in the Frontend! No more wasting time splitting your resources across multiple languages, using badly engineered, over-engineered, or premature-optimization-obsessed JavaScript libraries, fighting JavaScript build issues (e.g. webpack), or rewriting Ruby Backend code in Frontend JavaScript. With [Ruby in the Browser](https://www.youtube.com/watch?v=4AdcfbI6A4c), you can have an exponential jump in development productivity (2x or higher), time-to-release (1/2 or less time), cost (1/2 or cheaper), and maintainability (~50% the code that is simpler and more readable) over JavaScript libraries like React, Angular, Ember, Vue, and Svelte, while being able to reuse Backend Ruby code as is in the Frontend for faster interactions when needed. Also, with Frontend Ruby, companies can cut their hiring budget in half by having Backend Ruby Software Engineers do Frontend Development in Ruby! [Ruby in the Browser](https://www.youtube.com/watch?v=4AdcfbI6A4c) finally fulfills every smart highly-productive Rubyist's dream by bringing Ruby productivity fun to Frontend Development, the same productivity fun you had for years and decades in Backend Development.
|
14
14
|
|
15
15
|
[Glimmer](https://github.com/AndyObtiva/glimmer) DSL for Web enables building Web Frontends using [Ruby in the Browser](https://www.youtube.com/watch?v=4AdcfbI6A4c), as per [Matz's recommendation in his RubyConf 2022 keynote speech to replace JavaScript with Ruby](https://youtu.be/knutsgHTrfQ?t=789). It supports Rails' principle of the One Person Framework by not requiring any extra developers with JavaScript expertise, yet enabling Ruby (Backend) Software Engineers to develop the Frontend with Ruby code that is better than any JavaScript code produced by JS developers. It aims at providing the simplest, most intuitive, most straight-forward, and most productive frontend framework in existence. The framework follows the Ruby way (with [DSLs](https://martinfowler.com/books/dsl.html) and [TIMTOWTDI](https://en.wiktionary.org/wiki/TMTOWTDI#English)) and the Rails way ([Convention over Configuration](https://rubyonrails.org/doctrine)) in building Isomorphic Ruby on Rails Applications. It provides a Ruby [HTML DSL](#usage), which uniquely enables writing both structure code and logic code in one language. It supports both Unidirectional (One-Way) [Data-Binding](#hello-data-binding) (using `<=`) and Bidirectional (Two-Way) [Data-Binding](#hello-data-binding) (using `<=>`). Dynamic rendering (and re-rendering) of HTML content is also supported via [Content Data-Binding](#hello-content-data-binding). Modular design is supported with [Glimmer Web Components](#hello-component). And, a Ruby CSS DSL is supported with the included [Glimmer DSL for CSS](https://github.com/AndyObtiva/glimmer-dsl-css). To automatically convert legacy HTML & CSS code to Glimmer DSL Ruby code, Software Engineers could use the included [`html_to_glimmer`](https://github.com/AndyObtiva/glimmer-dsl-xml#html-to-glimmer-converter) and [`css_to_glimmer`](https://github.com/AndyObtiva/glimmer-dsl-css#css-to-glimmer-converter) commands. Many [samples](#samples) are demonstrated in the [Rails sample app](https://github.com/AndyObtiva/sample-glimmer-dsl-web-rails7-app) (there is a very minimal [Standalone [No Rails] static site sample app](https://github.com/Largo/glimmer-dsl-web-standalone-demo) too). You can finally live in pure Rubyland on the Web in both the frontend and backend with [Glimmer DSL for Web](https://rubygems.org/gems/glimmer-dsl-web)!
|
16
16
|
|
@@ -379,7 +379,7 @@ Screenshot:
|
|
379
379
|
|
380
380
|
If you need to regenerate HTML element content dynamically, you can use Content Data-Binding to effortlessly
|
381
381
|
rebuild HTML elements based on changes in a Model attribute that provides the source data.
|
382
|
-
In this example, we generate multiple address forms based on the number of addresses the user has.
|
382
|
+
In this example, we generate multiple address forms based on the number of addresses the user has using `content(@user, :address_count)` (you can add a `computed_by: array_of_attributes` option if you want to re-render content based on changes to multiple attributes like `content(@user, computed_by: [:address_count, :street_count])`, which fires on changes to `address_count` or `street_count`) .
|
383
383
|
|
384
384
|
[lib/glimmer-dsl-web/samples/hello/hello_content_data_binding.rb](/lib/glimmer-dsl-web/samples/hello/hello_content_data_binding.rb)
|
385
385
|
|
@@ -468,7 +468,7 @@ Document.ready? do
|
|
468
468
|
div {
|
469
469
|
# Content Data-Binding is used to dynamically (re)generate content of div
|
470
470
|
# based on changes to @user.addresses, replacing older content on every change
|
471
|
-
content(@user, :
|
471
|
+
content(@user, :address_count) do
|
472
472
|
@user.addresses.each do |address|
|
473
473
|
div {
|
474
474
|
div(style: 'display: grid; grid-auto-columns: 80px 280px;') { |address_div|
|
@@ -1152,6 +1152,8 @@ Screenshot:
|
|
1152
1152
|
|
1153
1153
|
**Todo MVC**
|
1154
1154
|
|
1155
|
+
[Todo MVC Ruby Edition Is the One Todo MVC To Rule Them All!!!](https://andymaleh.blogspot.com/2024/06/todo-mvc-in-ruby-is-one-todo-mvc-to.html)
|
1156
|
+
|
1155
1157
|
```ruby
|
1156
1158
|
require 'glimmer-dsl-web'
|
1157
1159
|
|
@@ -1280,6 +1282,7 @@ Learn more about the differences between various [Glimmer](https://github.com/An
|
|
1280
1282
|
- [Hello, Paragraph!](#hello-paragraph)
|
1281
1283
|
- [Hello, Input (Date/Time)!](#hello-input-datetime)
|
1282
1284
|
- [Button Counter](#button-counter)
|
1285
|
+
- [Todo MVC](#todo-mvc)
|
1283
1286
|
- [Design Principles](#design-principles)
|
1284
1287
|
- [Supporting Libraries](#supporting-libraries)
|
1285
1288
|
- [Glimmer Process](#glimmer-process)
|
@@ -1326,7 +1329,7 @@ rails new glimmer_app_server
|
|
1326
1329
|
Add the following to `Gemfile`:
|
1327
1330
|
|
1328
1331
|
```
|
1329
|
-
gem 'glimmer-dsl-web', '~> 0.2.
|
1332
|
+
gem 'glimmer-dsl-web', '~> 0.2.8'
|
1330
1333
|
```
|
1331
1334
|
|
1332
1335
|
Run:
|
@@ -1553,7 +1556,7 @@ Disable the `webpacker` gem line in `Gemfile`:
|
|
1553
1556
|
Add the following to `Gemfile`:
|
1554
1557
|
|
1555
1558
|
```ruby
|
1556
|
-
gem 'glimmer-dsl-web', '~> 0.2.
|
1559
|
+
gem 'glimmer-dsl-web', '~> 0.2.8'
|
1557
1560
|
```
|
1558
1561
|
|
1559
1562
|
Run:
|
@@ -2411,9 +2414,9 @@ Screenshot:
|
|
2411
2414
|
|
2412
2415
|
#### Hello, Content Data-Binding!
|
2413
2416
|
|
2414
|
-
If you need to regenerate HTML element content dynamically, you can use Content Data-Binding to effortlessly
|
2415
|
-
rebuild HTML elements based on changes in a Model attribute that provides the source data.
|
2416
|
-
In this example, we generate multiple address forms based on the number of addresses the user has.
|
2417
|
+
If you need to regenerate (re-render) HTML element content dynamically, you can use Content Data-Binding to effortlessly
|
2418
|
+
rebuild (rerender) HTML elements based on changes in a Model attribute that provides the source data.
|
2419
|
+
In this example, we generate multiple address forms based on the number of addresses the user has using `content(@user, :address_count)` (you can add a `computed_by: array_of_attributes` option if you want to re-render content based on changes to multiple attributes like `content(@user, computed_by: [:address_count, :street_count])`, which fires on changes to `address_count` or `street_count`) .
|
2417
2420
|
|
2418
2421
|
[lib/glimmer-dsl-web/samples/hello/hello_content_data_binding.rb](/lib/glimmer-dsl-web/samples/hello/hello_content_data_binding.rb)
|
2419
2422
|
|
@@ -2501,8 +2504,8 @@ Document.ready? do
|
|
2501
2504
|
|
2502
2505
|
div {
|
2503
2506
|
# Content Data-Binding is used to dynamically (re)generate content of div
|
2504
|
-
# based on changes to @user.
|
2505
|
-
content(@user, :
|
2507
|
+
# based on changes to @user.address_count, replacing older content on every change
|
2508
|
+
content(@user, :address_count) do
|
2506
2509
|
@user.addresses.each do |address|
|
2507
2510
|
div {
|
2508
2511
|
div(style: 'display: grid; grid-auto-columns: 80px 280px;') { |address_div|
|
@@ -3253,6 +3256,108 @@ Screenshot:
|
|
3253
3256
|
|
3254
3257
|
![Button Counter](/images/glimmer-dsl-web-samples-regular-button-counter.gif)
|
3255
3258
|
|
3259
|
+
#### Todo MVC
|
3260
|
+
|
3261
|
+
[Todo MVC Ruby Edition Is the One Todo MVC To Rule Them All!!!](https://andymaleh.blogspot.com/2024/06/todo-mvc-in-ruby-is-one-todo-mvc-to.html)
|
3262
|
+
|
3263
|
+
[lib/glimmer-dsl-web/samples/regular/todo_mvc.rb](/lib/glimmer-dsl-web/samples/regular/todo_mvc.rb)
|
3264
|
+
|
3265
|
+
```ruby
|
3266
|
+
require 'glimmer-dsl-web'
|
3267
|
+
|
3268
|
+
require_relative 'todo_mvc/presenters/todo_presenter'
|
3269
|
+
|
3270
|
+
require_relative 'todo_mvc/views/new_todo_form'
|
3271
|
+
require_relative 'todo_mvc/views/todo_list'
|
3272
|
+
require_relative 'todo_mvc/views/todo_filters'
|
3273
|
+
require_relative 'todo_mvc/views/todo_mvc_footer'
|
3274
|
+
|
3275
|
+
class TodoMvc
|
3276
|
+
include Glimmer::Web::Component
|
3277
|
+
|
3278
|
+
before_render do
|
3279
|
+
@presenter = TodoPresenter.new
|
3280
|
+
end
|
3281
|
+
|
3282
|
+
after_render do
|
3283
|
+
@presenter.setup_filter_routes
|
3284
|
+
end
|
3285
|
+
|
3286
|
+
markup {
|
3287
|
+
div(class: 'todomvc') {
|
3288
|
+
section(class: 'todoapp') {
|
3289
|
+
new_todo_form(presenter: @presenter)
|
3290
|
+
|
3291
|
+
todo_list(presenter: @presenter)
|
3292
|
+
|
3293
|
+
todo_filters(presenter: @presenter)
|
3294
|
+
|
3295
|
+
style {
|
3296
|
+
todo_mvc_styles
|
3297
|
+
}
|
3298
|
+
}
|
3299
|
+
|
3300
|
+
todo_mvc_footer
|
3301
|
+
|
3302
|
+
on_remove do
|
3303
|
+
@presenter.unsetup_filter_routes
|
3304
|
+
end
|
3305
|
+
}
|
3306
|
+
}
|
3307
|
+
|
3308
|
+
def todo_mvc_styles
|
3309
|
+
rule('body, button, html') {
|
3310
|
+
margin '0'
|
3311
|
+
padding '0'
|
3312
|
+
}
|
3313
|
+
|
3314
|
+
rule('button') {
|
3315
|
+
_webkit_font_smoothing 'antialiased'
|
3316
|
+
_webkit_appearance 'none'
|
3317
|
+
appearance 'none'
|
3318
|
+
background 'none'
|
3319
|
+
border '0'
|
3320
|
+
color 'inherit'
|
3321
|
+
font_family 'inherit'
|
3322
|
+
font_size '100%'
|
3323
|
+
font_weight 'inherit'
|
3324
|
+
vertical_align 'baseline'
|
3325
|
+
}
|
3326
|
+
|
3327
|
+
rule('.todoapp') {
|
3328
|
+
background '#fff'
|
3329
|
+
margin '130px 0 40px 0'
|
3330
|
+
position 'relative'
|
3331
|
+
box_shadow '0 2px 4px 0 rgba(0, 0, 0, 0.2), 0 25px 50px 0 rgba(0, 0, 0, 0.1)'
|
3332
|
+
}
|
3333
|
+
|
3334
|
+
media('screen and (-webkit-min-device-pixel-ratio:0)') {
|
3335
|
+
rule('body') {
|
3336
|
+
font "14px 'Helvetica Neue', Helvetica, Arial, sans-serif"
|
3337
|
+
line_height '1.4em'
|
3338
|
+
background '#f5f5f5'
|
3339
|
+
color '#111111'
|
3340
|
+
min_width '230px'
|
3341
|
+
max_width '550px'
|
3342
|
+
margin '0 auto'
|
3343
|
+
_webkit_font_smoothing 'antialiased'
|
3344
|
+
font_weight '300'
|
3345
|
+
}
|
3346
|
+
}
|
3347
|
+
end
|
3348
|
+
end
|
3349
|
+
|
3350
|
+
Document.ready? do
|
3351
|
+
TodoMvc.render
|
3352
|
+
end
|
3353
|
+
```
|
3354
|
+
|
3355
|
+
![Todo MVC](/images/glimmer-dsl-web-samples-regular-todo-mvc.gif)
|
3356
|
+
|
3357
|
+
The rest of the files are found at:
|
3358
|
+
|
3359
|
+
[lib/glimmer-dsl-web/samples/regular/todo_mvc](/lib/glimmer-dsl-web/samples/regular/todo_mvc)
|
3360
|
+
|
3256
3361
|
## Design Principles
|
3257
3362
|
|
3258
3363
|
- The Ruby Way (including TIMTOWTDI: There Is More Than One Way To Do It)
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.2.
|
1
|
+
0.2.8
|
data/glimmer-dsl-web.gemspec
CHANGED
@@ -2,16 +2,16 @@
|
|
2
2
|
# DO NOT EDIT THIS FILE DIRECTLY
|
3
3
|
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
4
|
# -*- encoding: utf-8 -*-
|
5
|
-
# stub: glimmer-dsl-web 0.2.
|
5
|
+
# stub: glimmer-dsl-web 0.2.8 ruby lib
|
6
6
|
|
7
7
|
Gem::Specification.new do |s|
|
8
8
|
s.name = "glimmer-dsl-web".freeze
|
9
|
-
s.version = "0.2.
|
9
|
+
s.version = "0.2.8"
|
10
10
|
|
11
11
|
s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version=
|
12
12
|
s.require_paths = ["lib".freeze]
|
13
13
|
s.authors = ["Andy Maleh".freeze]
|
14
|
-
s.date = "2024-06-
|
14
|
+
s.date = "2024-06-21"
|
15
15
|
s.description = "Glimmer DSL for Web (Ruby in the Browser Web Frontend Framework) enables building Web Frontends using Ruby in the Browser, as per Matz's recommendation in his RubyConf 2022 keynote speech to replace JavaScript with Ruby. It aims at providing the simplest, most intuitive, most straight-forward, and most productive frontend framework in existence. The framework follows the Ruby way (with DSLs and TIMTOWTDI) and the Rails way (Convention over Configuration) in building Isomorphic Ruby on Rails Applications. It provides a Ruby HTML DSL, which uniquely enables writing both structure code and logic code in one language. It supports both Unidirectional (One-Way) Data-Binding (using <=) and Bidirectional (Two-Way) Data-Binding (using <=>). Dynamic rendering (and re-rendering) of HTML content is also supported via Content Data-Binding. Modular design is supported with Glimmer Web Components. And, a Ruby CSS DSL is supported with the included Glimmer DSL for CSS. Many samples are demonstrated in the Rails sample app (there is a very minimal Standalone [No Rails] sample app too). You can finally live in pure Rubyland on the Web in both the frontend and backend with Glimmer DSL for Web! This gem relies on Opal Ruby.".freeze
|
16
16
|
s.email = "andy.am@gmail.com".freeze
|
17
17
|
s.extra_rdoc_files = [
|
@@ -526,8 +526,9 @@ module Glimmer
|
|
526
526
|
children.dup.each { |child| child.remove }
|
527
527
|
content(&content_block)
|
528
528
|
end
|
529
|
+
model_binding_observer = Glimmer::DataBinding::ModelBinding.new(*binding_args)
|
529
530
|
content_binding_observer = Glimmer::DataBinding::Observer.proc(&content_binding_work)
|
530
|
-
content_binding_observer.observe(
|
531
|
+
content_binding_observer.observe(model_binding_observer)
|
531
532
|
content_binding_work.call # TODO inspect if we need to pass args here (from observed attributes) [but it's simpler not to pass anything at first]
|
532
533
|
end
|
533
534
|
|
@@ -100,8 +100,8 @@ Document.ready? do
|
|
100
100
|
|
101
101
|
div {
|
102
102
|
# Content Data-Binding is used to dynamically (re)generate content of div
|
103
|
-
# based on changes to @user.
|
104
|
-
content(@user, :
|
103
|
+
# based on changes to @user.address_count, replacing older content on every change
|
104
|
+
content(@user, :address_count) do
|
105
105
|
@user.addresses.each do |address|
|
106
106
|
div {
|
107
107
|
div(style: 'display: grid; grid-auto-columns: 80px 280px;') { |address_div|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: glimmer-dsl-web
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andy Maleh
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-06-
|
11
|
+
date: 2024-06-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: glimmer
|