glimmer-dsl-web 0.7.0 → 0.7.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1ff3ef1efa40dc4dcc6e202544e7d0fa7be60c80d1f3dc9c465ed27cf62610df
4
- data.tar.gz: da8851cd3e896f236c5cf45b23ff234ceb5854a6814a213e7311bc5f553910f8
3
+ metadata.gz: 6fa66088970372c55644a8ffe63929208eb2ff33f70210fbb37c9df47c640553
4
+ data.tar.gz: 3322387162239687f62b4dd3ea7c1d1d34d52bda6e1242960dd9e6e7d8cf0f0a
5
5
  SHA512:
6
- metadata.gz: 145f156c520f3e25b0f4251fba654fcac9668edf5e03473aa4891fcf970ea92189d8a64be0f93f7fcbd81a9fc28ae541ccf6c99088ce64bbeb9eb9bb97c65450
7
- data.tar.gz: 53ab737627d2cc6fac28e94f6e372a46f9a21af784afb5c4618509a874a684ff574eb85aa6a5a6c469b264c36257c5f66e8469f9d9825442e119341d9e1210ce
6
+ metadata.gz: 6cd62b7128c8da53cb68a359ed633724439671877e485c17bda919fca70f7e5d80c10fda3720072b9f7e6fdcd5c1f6fb0ec1652539fa9e864234779ef5bea267
7
+ data.tar.gz: 0e2c789e2eb779f9fb5e0a70bc22da3ece42d0e9c1efcb77fd965a39c93e380142ca082b131fada732e25ce4b22ef131f5292af91d9cfe94cd7e19c2ce7229b9
data/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # Change Log
2
2
 
3
+ ## 0.7.2
4
+
5
+ - Hello, Component Attribute Listeners! Sample: `require 'glimmer-dsl-web/samples/hello/hello_component_attribute_listeners.rb'`
6
+
7
+ ## 0.7.1
8
+
9
+ - Fix issue with not being able to pass arguments containing apostrophe (') to glimmer_component helper (provided by GlimmerHelper)
10
+
3
11
  ## 0.7.0
4
12
 
5
13
  - Rename `element-ID` element CSS classes to `glimmer-element-ID` for a more unique class name that nobody else would be using
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.7.0 (Beta)
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.7.2 (Beta)
2
2
  ## Ruby-in-the-Browser Web Frontend Framework
3
3
  ### The "Rails" of Frontend Frameworks!!! ([Fukuoka Award Winning](https://andymaleh.blogspot.com/2025/01/glimmer-dsl-for-web-wins-in-fukuoka.html))
4
4
  #### Finally, Ruby Developer Productivity, Happiness, and Fun in the Frontend!!!
@@ -7,7 +7,7 @@
7
7
 
8
8
  **(Based on Original [Glimmer](https://github.com/AndyObtiva/glimmer) Library Handling World’s Ruby GUI Needs Since 2007. Beware of Imitators!)**
9
9
 
10
- **([Fukuoka Prefecture Future IT Initiative 2025 Money Forward Award Winner](https://andymaleh.blogspot.com/2025/01/glimmer-dsl-for-web-wins-in-fukuoka.html))**
10
+ **([Fukuoka Prefecture Future IT Initiative 2025 Money Forward Award Winner](https://andymaleh.blogspot.com/2025/01/glimmer-dsl-for-web-wins-in-fukuoka.html)) [(Award Announcement)](https://digitalfukuoka.jp/news/info/528/)**
11
11
 
12
12
  **(Talk Videos: [Intro to Ruby in the Browser](https://youtu.be/4AdcfbI6A4c?si=MmxOrkhIXTDHQoYi) / [Frontend Ruby with Glimmer DSL for Web \[Montreal.rb\]](https://youtu.be/rIZ-ILUv9ME?si=raygUXVPd_7ypWuE) / [Frontend Ruby with Glimmer DSL for Web \[/dev/mtl 2024\]](https://www.youtube.com/watch?v=J2VIY9DMJo4))**
13
13
 
@@ -17,7 +17,7 @@
17
17
 
18
18
  **Endorsement:** *"I'd like to endorse Andy Maleh’s work (Glimmer DSL for Web). I got introduced to it at RubyConf 2024 and have been playing around with it pretty successfully. What I have found most interesting is that I have been writing inside of a rails app, where I have been running the same code for models and presenters inside of MRI rspec. That way I can write tests that verify behavior of the presenters and models and still see them run successfully in the browser. That allows me to have a very nice cycle of refactoring and being confident in my changes without even running it in browser. I just assume that the binding will work and it usually works perfectly."* - Steve Tuckner on January 9, 2024
19
19
 
20
- 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)! [Glimmer](https://github.com/AndyObtiva/glimmer) DSL for Web enables building Web Frontends (aka SPA: Single Page Applications) 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) (including full support for [SVG](#hello-svg)), 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), [Component Slots](#hello-component-slots), Component Attribute Listeners, and [Component Custom Event Listeners](#hello-component-listeners). 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).
20
+ 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)! [Glimmer](https://github.com/AndyObtiva/glimmer) DSL for Web enables building Web Frontends (aka SPA: Single Page Applications) 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) (including full support for [SVG](#hello-svg)), 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) (including a standalone general components gem called [glimmer-web-components](https://github.com/AndyObtiva/glimmer-web-components)), [Component Slots](#hello-component-slots), Component Attribute Listeners, and [Component Custom Event Listeners](#hello-component-listeners). 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).
21
21
 
22
22
  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 SPA (Single Page Applications), 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.
23
23
 
@@ -31,7 +31,7 @@ Anyone not considering this kind of technology in 2024 is like someone stuck in
31
31
 
32
32
  **Hello, World! Sample**
33
33
 
34
- (Note: in real app development, we build [Glimmer Web Components](#hello-component), but this sample is just introducing basic building blocks towards building [components](#hello-component))
34
+ (Note: in real app development, we build [Glimmer Web Components](#hello-component) and we rely on the [glimmer_component Rails Helper](#hello-glimmer_component-rails-helper) to embed components in ERB Views without needing `Document.ready?`, but this sample is just introducing basic building blocks towards building [components](#hello-component))
35
35
 
36
36
  [lib/glimmer-dsl-web/samples/hello/hello_world.rb](/lib/glimmer-dsl-web/samples/hello/hello_world.rb)
37
37
 
@@ -63,7 +63,7 @@ You can also mount the `div` elsewhere by passing the `parent: parent_css_select
63
63
 
64
64
  **Hello, Button!**
65
65
 
66
- (Note: in real app development, we build [Glimmer Web Components](#hello-component), but this sample is just introducing basic building blocks towards building [components](#hello-component))
66
+ (Note: in real app development, we build [Glimmer Web Components](#hello-component) and we rely on the [glimmer_component Rails Helper](#hello-glimmer_component-rails-helper) to embed components in ERB Views without needing `Document.ready?`, but this sample is just introducing basic building blocks towards building [components](#hello-component))
67
67
 
68
68
  Event listeners can be setup on any element using the same event names used in HTML (e.g. `onclick`) while passing in a standard Ruby block to handle behavior. `$$` gives access to JS global scope from Ruby to invoke functions like `alert`.
69
69
 
@@ -101,7 +101,7 @@ Screenshot:
101
101
 
102
102
  **Hello, Form!**
103
103
 
104
- (Note: in real app development, we build [Glimmer Web Components](#hello-component), but this sample is just introducing basic building blocks towards building [components](#hello-component))
104
+ (Note: in real app development, we build [Glimmer Web Components](#hello-component) and we rely on the [glimmer_component Rails Helper](#hello-glimmer_component-rails-helper) to embed components in ERB Views without needing `Document.ready?`, but this sample is just introducing basic building blocks towards building [components](#hello-component))
105
105
 
106
106
  [Glimmer DSL for Web](https://rubygems.org/gems/glimmer-dsl-web) gives access to all Web Browser built-in features like HTML form validations, input focus, events, and element functions from a very terse and productive Ruby HTML DSL. Also, you can apply CSS styles by including directly in Ruby code as a string, using [Glimmer DSL for CSS](https://github.com/AndyObtiva/glimmer-dsl-css), or managing CSS completely separately using something like [SCSS](https://sass-lang.com/). The CSS techniques could be combined as well, like by managing common reusable CSS styles separately in SCSS, but adding component specific CSS styles in Ruby when it is more convenient.
107
107
 
@@ -261,7 +261,7 @@ Screenshot:
261
261
 
262
262
  **Hello, Data-Binding!**
263
263
 
264
- (Note: in real app development, we build [Glimmer Web Components](#hello-component), but this sample is just introducing basic building blocks towards building [components](#hello-component))
264
+ (Note: in real app development, we build [Glimmer Web Components](#hello-component) and we rely on the [glimmer_component Rails Helper](#hello-glimmer_component-rails-helper) to embed components in ERB Views without needing `Document.ready?`, but this sample is just introducing basic building blocks towards building [components](#hello-component))
265
265
 
266
266
  [Glimmer DSL for Web](https://rubygems.org/gems/glimmer-dsl-web) intuitively supports both Unidirectional (One-Way) Data-Binding via the `<=` operator and Bidirectional (Two-Way) Data-Binding via the `<=>` operator, incredibly simplifying how to sync View properties with Model attributes with the simplest code to reason about.
267
267
 
@@ -438,7 +438,7 @@ Screenshot:
438
438
 
439
439
  **Hello, Content Data-Binding!**
440
440
 
441
- (Note: in real app development, we build [Glimmer Web Components](#hello-component), but this sample is just introducing basic building blocks towards building [components](#hello-component))
441
+ (Note: in real app development, we build [Glimmer Web Components](#hello-component) and we rely on the [glimmer_component Rails Helper](#hello-glimmer_component-rails-helper) to embed components in ERB Views without needing `Document.ready?`, but this sample is just introducing basic building blocks towards building [components](#hello-component))
442
442
 
443
443
  If you need to regenerate HTML element content dynamically, you can use Content Data-Binding to effortlessly
444
444
  rebuild HTML elements based on changes in a Model attribute that provides the source data.
@@ -1348,10 +1348,11 @@ Learn more about the differences between various [Glimmer](https://github.com/An
1348
1348
  - [Hello, Observer (Data-Binding)!](#hello-observer)
1349
1349
  - [Hello, Data-Binding!](#hello-data-binding)
1350
1350
  - [Hello, Content Data-Binding!](#hello-content-data-binding)
1351
- - [Hello, Component!](#hello-compoent)
1351
+ - [Hello, Component!](#hello-component)
1352
1352
  - [Hello, Component Slots!](#hello-component-slots)
1353
- - [Hello, Component Listeners!](#hello-compoent-listeners)
1354
- - [Hello, Component Listeners (Default Slot)!](#hello-compoent-listeners-default-slot)
1353
+ - [Hello, Component Listeners!](#hello-component-listeners)
1354
+ - [Hello, Component Listeners (Default Slot)!](#hello-component-listeners-default-slot)
1355
+ - [Hello, Component Attribute Listeners!](#hello-component-attribute-listeners)
1355
1356
  - [Hello, glimmer_component Rails Helper!](#hello-glimmer_component-rails-helper)
1356
1357
  - [Hello, Paragraph!](#hello-paragraph)
1357
1358
  - [Hello, Style!](#hello-style)
@@ -1387,6 +1388,14 @@ Once done, read [Usage](#usage) instructions. Note that for serious app usage, i
1387
1388
 
1388
1389
  (NOTE: Keep in mind this is a Beta. If you run into issues, read the [FAQ](#faq) in case they are addressed there (e.g. [I sometimes get an Opal error that makes no sense in relation to my code. How do I fix it?](https://github.com/AndyObtiva/glimmer-dsl-web/blob/master/README.md#i-sometimes-get-an-opal-error-that-makes-no-sense-in-relation-to-my-code-how-do-i-fix-it)) and try to go back to a [previous revision](https://rubygems.org/gems/glimmer-dsl-web/versions). Also, there is a slight chance any issues you encounter are fixed in master or some other branch that you could check out instead)
1389
1390
 
1391
+ ### Rails 8
1392
+
1393
+ Rails 8 instructions are not ready yet though they would rely on the `opal --watch` command in the Development environment to generate JavaScript files in the directory that propshaft is setup with, and Rails 8 would rely on the `opal` command to generate JavaScript files for the Production environment.
1394
+
1395
+ Instructions will be added in the future.
1396
+
1397
+ If you want to help contribute Rails 8 instructions, please look at the Rails 7 instructions and see what needs to be adjusted in light of the first statement above about using `opal --watch` in Development and `opal` in Production.
1398
+
1390
1399
  ### Rails 7
1391
1400
 
1392
1401
  (NOTE: In the future, we plan to automate the setup steps below. If you would like to help contribute that to the project, please do so and open a Pull Request.)
@@ -1408,7 +1417,7 @@ rails new glimmer_app_server
1408
1417
  Add the following to `Gemfile`:
1409
1418
 
1410
1419
  ```
1411
- gem 'glimmer-dsl-web', '~> 0.7.0'
1420
+ gem 'glimmer-dsl-web', '~> 0.7.2'
1412
1421
  ```
1413
1422
 
1414
1423
  Run:
@@ -3750,6 +3759,83 @@ Screenshot:
3750
3759
 
3751
3760
  ![Hello, Component Listeners!](/images/glimmer-dsl-web-samples-hello-hello-component-listeners.gif)
3752
3761
 
3762
+ #### Hello, Component Attribute Listeners!
3763
+
3764
+ [lib/glimmer-dsl-web/samples/hello/hello_component_attribute_listeners.rb](/lib/glimmer-dsl-web/samples/hello/hello_component_attribute_listeners.rb)
3765
+
3766
+ Glimmer HTML DSL Ruby code in the frontend:
3767
+
3768
+ ```ruby
3769
+ require 'glimmer-dsl-web'
3770
+
3771
+ unless Object.const_defined?(:AddressTypeSelector)
3772
+ class AddressTypeSelector
3773
+ include Glimmer::Web::Component
3774
+
3775
+ attribute :address_types, default: []
3776
+ attribute :selected_address_type
3777
+
3778
+ before_render do
3779
+ self.selected_address_type ||= address_types.first
3780
+ end
3781
+
3782
+ markup {
3783
+ select(placeholder: 'Select an address type') { |select_element|
3784
+ address_types.each do |address_type|
3785
+ option(value: address_type) { address_type }
3786
+ end
3787
+
3788
+ # Bidirectionally data-bind select value to selected_address_type attribute on self (component)
3789
+ value <=> [self, :selected_address_type]
3790
+ }
3791
+ }
3792
+
3793
+ style {
3794
+ r(component_element_selector) {
3795
+ font_size 2.em
3796
+ margin_left 5.px
3797
+ }
3798
+ }
3799
+ end
3800
+ end
3801
+
3802
+ unless Object.const_defined?(:AddressTypeSelectorPage)
3803
+ class AddressTypeSelectorPage
3804
+ include Glimmer::Web::Component
3805
+
3806
+ markup {
3807
+ div {
3808
+ h1('Address type for delivery:', style: {display: :inline})
3809
+
3810
+ address_type_selector(address_types: ['Home', 'Work', 'Other']) {
3811
+ # We can listen to the updates of any attribute/option in a Glimmer Web Component
3812
+ # on_{attribute_name}_update do execute code when component attribute/option with attribute_name is updated
3813
+ # This is an alternative to using Component Listeners, which require that the component explicitly calls notify_listeners,
3814
+ # whereas Component Attribute Listeners get tracked automatically, but depend on a specific attribute
3815
+ # The trade-off is Component Listeners provide more flexibility when needed as they are not bound to specific attributes,
3816
+ # but often Component Attribute Listeners are good enough as a solution for certain problems.
3817
+ on_selected_address_type_update do |address_type|
3818
+ $$.alert("You selected the address type: #{address_type}")
3819
+ end
3820
+ }
3821
+ }
3822
+ }
3823
+ end
3824
+ end
3825
+
3826
+ Document.ready? do
3827
+ AddressTypeSelectorPage.render
3828
+ end
3829
+ ```
3830
+
3831
+ Screenshot:
3832
+
3833
+ ![Hello, Component Attribute Listeners!](/images/glimmer-dsl-web-samples-hello-hello-component-attribute-listeners.png)
3834
+
3835
+ ![Hello, Component Attribute Listeners Selected Address Type!](/images/glimmer-dsl-web-samples-hello-hello-component-attribute-listeners-selected-address-type.png)
3836
+
3837
+ ![Hello, Component Attribute Listeners Selected Address Type Dialog!](/images/glimmer-dsl-web-samples-hello-hello-component-attribute-listeners-selected-address-type-dialog.png)
3838
+
3753
3839
  #### Hello, glimmer_component Rails Helper!
3754
3840
 
3755
3841
  You may insert a Glimmer component anywhere into a Rails View using
@@ -4599,6 +4685,11 @@ Here is a list of notable 3rd party gems used by Glimmer DSL for Web:
4599
4685
  - [opal-async](https://github.com/AndyObtiva/opal-async): Non-blocking tasks and enumerators for Web.
4600
4686
  - [to_collection](https://github.com/AndyObtiva/to_collection): Treat an array of objects and a singular object uniformly as a collection of objects.
4601
4687
 
4688
+ Here is a list of 3rd party gems that compliment Glimmer DSL for Web:
4689
+ - [glimmer-web-components](https://github.com/AndyObtiva/glimmer-web-components)
4690
+
4691
+ ![glimmer-web-components](https://github.com/AndyObtiva/glimmer-web-components/raw/master/screenshots/glimmer-web-components-multi-checkbox-dropdown.gif)
4692
+
4602
4693
  ## Influences and Inspiration
4603
4694
 
4604
4695
  - https://github.com/inesita-rb/inesita
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.7.0
1
+ 0.7.2
@@ -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.7.0 ruby lib
5
+ # stub: glimmer-dsl-web 0.7.2 ruby lib
6
6
 
7
7
  Gem::Specification.new do |s|
8
8
  s.name = "glimmer-dsl-web".freeze
9
- s.version = "0.7.0"
9
+ s.version = "0.7.2".freeze
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 = "2025-03-01"
14
+ s.date = "1980-01-02"
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, Component Slots, and Component Custom Event Listeners. 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 = [
@@ -33,6 +33,7 @@ Gem::Specification.new do |s|
33
33
  "lib/glimmer-dsl-web/ext/kernel.rb",
34
34
  "lib/glimmer-dsl-web/samples/hello/hello_button.rb",
35
35
  "lib/glimmer-dsl-web/samples/hello/hello_component.rb",
36
+ "lib/glimmer-dsl-web/samples/hello/hello_component_attribute_listeners.rb",
36
37
  "lib/glimmer-dsl-web/samples/hello/hello_component_listeners.rb",
37
38
  "lib/glimmer-dsl-web/samples/hello/hello_component_listeners_default_slot.rb",
38
39
  "lib/glimmer-dsl-web/samples/hello/hello_component_slots.rb",
@@ -98,24 +99,24 @@ Gem::Specification.new do |s|
98
99
  ]
99
100
  s.homepage = "http://github.com/AndyObtiva/glimmer-dsl-web".freeze
100
101
  s.licenses = ["MIT".freeze]
101
- s.rubygems_version = "3.4.10".freeze
102
+ s.rubygems_version = "3.6.7".freeze
102
103
  s.summary = "Glimmer DSL for Web (Ruby in the Browser Web Frontend Framework)".freeze
103
104
 
104
105
  s.specification_version = 4
105
106
 
106
- s.add_runtime_dependency(%q<glimmer>.freeze, ["~> 2.8.0"])
107
- s.add_runtime_dependency(%q<glimmer-dsl-xml>.freeze, ["~> 1.4.0"])
108
- s.add_runtime_dependency(%q<glimmer-dsl-css>.freeze, ["~> 1.5.2"])
109
- s.add_runtime_dependency(%q<opal>.freeze, ["= 1.8.2"])
110
- s.add_runtime_dependency(%q<opal-rails>.freeze, ["~> 2.0.4"])
111
- s.add_runtime_dependency(%q<opal-async>.freeze, ["~> 1.4.1"])
112
- s.add_runtime_dependency(%q<opal-jquery>.freeze, ["~> 0.5.2"])
113
- s.add_runtime_dependency(%q<to_collection>.freeze, [">= 2.0.1", "< 3.0.0"])
114
- s.add_development_dependency(%q<puts_debuggerer>.freeze, [">= 1.0.1"])
115
- s.add_development_dependency(%q<rake>.freeze, [">= 10.1.0", "< 14.0.0"])
116
- s.add_development_dependency(%q<rake-tui>.freeze, [">= 0"])
117
- s.add_development_dependency(%q<jeweler>.freeze, [">= 2.3.9", "< 3.0.0"])
118
- s.add_development_dependency(%q<rdoc>.freeze, [">= 6.2.1", "< 7.0.0"])
119
- s.add_development_dependency(%q<opal-rspec>.freeze, ["~> 0.8.0.alpha2"])
107
+ s.add_runtime_dependency(%q<glimmer>.freeze, ["~> 2.8.0".freeze])
108
+ s.add_runtime_dependency(%q<glimmer-dsl-xml>.freeze, ["~> 1.4.0".freeze])
109
+ s.add_runtime_dependency(%q<glimmer-dsl-css>.freeze, ["~> 1.5.2".freeze])
110
+ s.add_runtime_dependency(%q<opal>.freeze, ["= 1.8.2".freeze])
111
+ s.add_runtime_dependency(%q<opal-rails>.freeze, ["~> 2.0.4".freeze])
112
+ s.add_runtime_dependency(%q<opal-async>.freeze, ["~> 1.4.1".freeze])
113
+ s.add_runtime_dependency(%q<opal-jquery>.freeze, ["~> 0.5.2".freeze])
114
+ s.add_runtime_dependency(%q<to_collection>.freeze, [">= 2.0.1".freeze, "< 3.0.0".freeze])
115
+ s.add_development_dependency(%q<puts_debuggerer>.freeze, [">= 1.0.1".freeze])
116
+ s.add_development_dependency(%q<rake>.freeze, [">= 10.1.0".freeze, "< 14.0.0".freeze])
117
+ s.add_development_dependency(%q<rake-tui>.freeze, [">= 0".freeze])
118
+ s.add_development_dependency(%q<jeweler>.freeze, [">= 2.3.9".freeze, "< 3.0.0".freeze])
119
+ s.add_development_dependency(%q<rdoc>.freeze, [">= 6.2.1".freeze, "< 7.0.0".freeze])
120
+ s.add_development_dependency(%q<opal-rspec>.freeze, ["~> 0.8.0.alpha2".freeze])
120
121
  end
121
122
 
@@ -12,10 +12,11 @@ module GlimmerHelper
12
12
  next_id_number = GlimmerHelper.next_id_number
13
13
  component_id = "glimmer_component_#{next_id_number}"
14
14
  component_script_container_id = "glimmer_component_script_container_#{next_id_number}"
15
+ component_script_tag_id = "glimmer_component_script_#{next_id_number}"
15
16
  component_args_json = JSON.dump(component_args)
16
17
  opal_script = <<~OPAL
17
18
  require 'glimmer-dsl-web'
18
- component_args_json = '#{component_args_json}'
19
+ component_args_json = $$.document.getElementById("#{component_script_tag_id}").dataset.componentArgs
19
20
  component_args = JSON.parse(component_args_json)
20
21
  component_args << {} if !component_args.last.is_a?(Hash)
21
22
  component_args.last[:parent] = "##{component_id}"
@@ -27,7 +28,7 @@ module GlimmerHelper
27
28
  content_tag(:div, id: component_script_container_id, class: ['glimmer_component_script_container', "#{component_file}_script_container"], 'data-turbo': 'false') do
28
29
  content_tag(:div, '', id: component_id, class: ['glimmer_component', component_file]) +
29
30
  javascript_include_tag(component_asset_path, "data-turbolinks-track": "reload") +
30
- content_tag(:script, raw(js_script), type: 'application/javascript', "data-turbo-eval": "false")
31
+ content_tag(:script, raw(js_script), id: component_script_tag_id, type: 'application/javascript', "data-turbo-eval": "false", "data-component-args": component_args_json)
31
32
  end
32
33
  end
33
34
  end
@@ -476,6 +476,8 @@ module Glimmer
476
476
  end
477
477
  end
478
478
 
479
+ alias to_s dom
480
+
479
481
  def children_dom_content
480
482
  children.map(&:dom).join
481
483
  end
@@ -0,0 +1,81 @@
1
+ # Copyright (c) 2023-2024 Andy Maleh
2
+ #
3
+ # Permission is hereby granted, free of charge, to any person obtaining
4
+ # a copy of this software and associated documentation files (the
5
+ # "Software"), to deal in the Software without restriction, including
6
+ # without limitation the rights to use, copy, modify, merge, publish,
7
+ # distribute, sublicense, and/or sell copies of the Software, and to
8
+ # permit persons to whom the Software is furnished to do so, subject to
9
+ # the following conditions:
10
+ #
11
+ # The above copyright notice and this permission notice shall be
12
+ # included in all copies or substantial portions of the Software.
13
+ #
14
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21
+
22
+ require 'glimmer-dsl-web'
23
+
24
+ unless Object.const_defined?(:AddressTypeSelector)
25
+ class AddressTypeSelector
26
+ include Glimmer::Web::Component
27
+
28
+ attribute :address_types, default: []
29
+ attribute :selected_address_type
30
+
31
+ before_render do
32
+ self.selected_address_type ||= address_types.first
33
+ end
34
+
35
+ markup {
36
+ select(placeholder: 'Select an address type') { |select_element|
37
+ address_types.each do |address_type|
38
+ option(value: address_type) { address_type }
39
+ end
40
+
41
+ # Bidirectionally data-bind select value to selected_address_type attribute on self (component)
42
+ value <=> [self, :selected_address_type]
43
+ }
44
+ }
45
+
46
+ style {
47
+ r(component_element_selector) {
48
+ font_size 2.em
49
+ margin_left 5.px
50
+ }
51
+ }
52
+ end
53
+ end
54
+
55
+ unless Object.const_defined?(:AddressTypeSelectorPage)
56
+ class AddressTypeSelectorPage
57
+ include Glimmer::Web::Component
58
+
59
+ markup {
60
+ div {
61
+ h1('Address type for delivery:', style: {display: :inline})
62
+
63
+ address_type_selector(address_types: ['Home', 'Work', 'Other']) {
64
+ # We can listen to the updates of any attribute/option in a Glimmer Web Component
65
+ # on_{attribute_name}_update do execute code when component attribute/option with attribute_name is updated
66
+ # This is an alternative to using Component Listeners, which require that the component explicitly calls notify_listeners,
67
+ # whereas Component Attribute Listeners get tracked automatically, but depend on a specific attribute
68
+ # The trade-off is Component Listeners provide more flexibility when needed as they are not bound to specific attributes,
69
+ # but often Component Attribute Listeners are good enough as a solution for certain problems.
70
+ on_selected_address_type_update do |address_type|
71
+ $$.alert("You selected the address type: #{address_type}")
72
+ end
73
+ }
74
+ }
75
+ }
76
+ end
77
+ end
78
+
79
+ Document.ready? do
80
+ AddressTypeSelectorPage.render
81
+ end
@@ -21,10 +21,10 @@
21
21
 
22
22
  require 'opal'
23
23
 
24
- GLIMMER_DSL_OPAL_ROOT = File.expand_path('../..', __FILE__)
25
- GLIMMER_DSL_OPAL_LIB = File.join(GLIMMER_DSL_OPAL_ROOT, 'lib')
24
+ GLIMMER_DSL_WEB_ROOT = File.expand_path('../..', __FILE__)
25
+ GLIMMER_DSL_WEB_LIB = File.join(GLIMMER_DSL_WEB_ROOT, 'lib')
26
26
 
27
- $LOAD_PATH.unshift(GLIMMER_DSL_OPAL_LIB)
27
+ $LOAD_PATH.unshift(GLIMMER_DSL_WEB_LIB)
28
28
 
29
29
  if RUBY_ENGINE != 'opal'
30
30
  require 'opal-rails'
@@ -32,12 +32,12 @@ if RUBY_ENGINE != 'opal'
32
32
  require 'opal-jquery'
33
33
  require 'glimmer/helpers/glimmer_helper'
34
34
  else
35
- # GLIMMER_DSL_OPAL_MISSING = File.join(GLIMMER_DSL_OPAL_ROOT, 'lib', 'glimmer-dsl-opal', 'missing')
35
+ # GLIMMER_DSL_WEB_MISSING = File.join(GLIMMER_DSL_WEB_ROOT, 'lib', 'glimmer-dsl-opal', 'missing')
36
36
 
37
- # $LOAD_PATH.unshift(GLIMMER_DSL_OPAL_MISSING) # missing Ruby classes/methods
37
+ # $LOAD_PATH.unshift(GLIMMER_DSL_WEB_MISSING) # missing Ruby classes/methods
38
38
  # TODO look into making append_path work (causing some trouble right now)
39
39
  # Opal.append_path File.expand_path('../glimmer-dsl-opal/missing', __FILE__)
40
- # Opal.append_path GLIMMER_DSL_OPAL_MISSING
40
+ # Opal.append_path GLIMMER_DSL_WEB_MISSING
41
41
  module Kernel
42
42
  def include_package(package)
43
43
  # No Op (just a shim)
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: glimmer-dsl-web
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.0
4
+ version: 0.7.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andy Maleh
8
- autorequire:
9
8
  bindir: bin
10
9
  cert_chain: []
11
- date: 2025-03-01 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
13
  name: glimmer
@@ -267,6 +266,7 @@ files:
267
266
  - lib/glimmer-dsl-web/ext/kernel.rb
268
267
  - lib/glimmer-dsl-web/samples/hello/hello_button.rb
269
268
  - lib/glimmer-dsl-web/samples/hello/hello_component.rb
269
+ - lib/glimmer-dsl-web/samples/hello/hello_component_attribute_listeners.rb
270
270
  - lib/glimmer-dsl-web/samples/hello/hello_component_listeners.rb
271
271
  - lib/glimmer-dsl-web/samples/hello/hello_component_listeners_default_slot.rb
272
272
  - lib/glimmer-dsl-web/samples/hello/hello_component_slots.rb
@@ -333,7 +333,6 @@ homepage: http://github.com/AndyObtiva/glimmer-dsl-web
333
333
  licenses:
334
334
  - MIT
335
335
  metadata: {}
336
- post_install_message:
337
336
  rdoc_options: []
338
337
  require_paths:
339
338
  - lib
@@ -348,8 +347,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
348
347
  - !ruby/object:Gem::Version
349
348
  version: '0'
350
349
  requirements: []
351
- rubygems_version: 3.4.10
352
- signing_key:
350
+ rubygems_version: 3.6.7
353
351
  specification_version: 4
354
352
  summary: Glimmer DSL for Web (Ruby in the Browser Web Frontend Framework)
355
353
  test_files: []