glimmer-dsl-web 0.7.3 → 0.8.0
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 +4 -4
- data/CHANGELOG.md +4 -0
- data/README.md +2 -2
- data/VERSION +1 -1
- data/glimmer-dsl-web.gemspec +2 -2
- data/lib/glimmer/dsl/web/formatting_element_expression.rb +17 -2
- data/lib/glimmer/web/element_proxy.rb +25 -5
- data/lib/glimmer/web/formatting_element_proxy.rb +9 -5
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f636fd9070bcacf8775433ffe589b81f7590710fa9605302b249a3c22be641c7
|
4
|
+
data.tar.gz: 2c40869f1eb9275701eb18c6f9555559b69f26358925845e0000445a143f5bc9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 188bcb0445c91ee19342cda641b15e810d80211c1e7c138315d71e83a3be741b5ba98bd0430b2ea5ed743f67c6bafdae15cec2f847d30a83da6f25eb9ad10674
|
7
|
+
data.tar.gz: c41e90e255713b6cd88537c2d34a47b7656c33e9af3c8bbbb70de000da040d26c769f28a16450f27c62aeb2f33cb5e5419412a2baffbc13aa760ed7b513376aa
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,9 @@
|
|
1
1
|
# Change Log
|
2
2
|
|
3
|
+
## 0.8.0
|
4
|
+
|
5
|
+
- Support formatting-paragraph-elements (e.g. 'br', 'strong', 'em') as stand-alone elements (not inside p)
|
6
|
+
|
3
7
|
## 0.7.3
|
4
8
|
|
5
9
|
- Hello, Component Attribute Data-Binding! Sample: `require 'glimmer-dsl-web/samples/hello/hello_component_attribute_data_binding.rb'`
|
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.
|
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.8.0 (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!!!
|
@@ -1418,7 +1418,7 @@ rails new glimmer_app_server
|
|
1418
1418
|
Add the following to `Gemfile`:
|
1419
1419
|
|
1420
1420
|
```
|
1421
|
-
gem 'glimmer-dsl-web', '~> 0.
|
1421
|
+
gem 'glimmer-dsl-web', '~> 0.8.0'
|
1422
1422
|
```
|
1423
1423
|
|
1424
1424
|
Run:
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.8.0
|
data/glimmer-dsl-web.gemspec
CHANGED
@@ -2,11 +2,11 @@
|
|
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.
|
5
|
+
# stub: glimmer-dsl-web 0.8.0 ruby lib
|
6
6
|
|
7
7
|
Gem::Specification.new do |s|
|
8
8
|
s.name = "glimmer-dsl-web".freeze
|
9
|
-
s.version = "0.
|
9
|
+
s.version = "0.8.0".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]
|
@@ -6,12 +6,27 @@ module Glimmer
|
|
6
6
|
module DSL
|
7
7
|
module Web
|
8
8
|
class FormattingElementExpression < Expression
|
9
|
+
include GeneralElementExpression
|
10
|
+
|
9
11
|
def can_interpret?(parent, keyword, *args, &block)
|
10
|
-
Glimmer::Web::FormattingElementProxy.keyword_supported?(keyword, parent: parent)
|
12
|
+
Glimmer::Web::FormattingElementProxy.keyword_supported?(keyword, parent: parent) ||
|
13
|
+
Glimmer::Web::ElementProxy.keyword_supported?(keyword)
|
11
14
|
end
|
12
15
|
|
13
16
|
def interpret(parent, keyword, *args, &block)
|
14
|
-
Glimmer::Web::FormattingElementProxy.
|
17
|
+
if Glimmer::Web::FormattingElementProxy.keyword_supported?(keyword, parent: parent)
|
18
|
+
Glimmer::Web::FormattingElementProxy.format(keyword, *args, &block)
|
19
|
+
else
|
20
|
+
super(parent, keyword, *args, &block)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def add_content(parent, keyword, *args, &block)
|
25
|
+
if parent.is_a?(String)
|
26
|
+
parent
|
27
|
+
else
|
28
|
+
super(parent, keyword, *args, &block)
|
29
|
+
end
|
15
30
|
end
|
16
31
|
end
|
17
32
|
end
|
@@ -28,7 +28,9 @@ module Glimmer
|
|
28
28
|
class ElementProxy
|
29
29
|
class << self
|
30
30
|
def keyword_supported?(keyword)
|
31
|
-
|
31
|
+
keyword = keyword.to_s
|
32
|
+
ELEMENT_KEYWORDS.include?(keyword) ||
|
33
|
+
FormattingElementProxy::FORMATTING_ELEMENT_KEYWORDS.include?(keyword)
|
32
34
|
end
|
33
35
|
|
34
36
|
def html_keyword_supported?(keyword)
|
@@ -39,6 +41,13 @@ module Glimmer
|
|
39
41
|
SVG_ELEMENT_KEYWORDS.include?(keyword.to_s)
|
40
42
|
end
|
41
43
|
|
44
|
+
# an HTML element that doesn't need a closing tag
|
45
|
+
# (officially, it's wrong to call it self-closing; it's called void instead)
|
46
|
+
def html_void_keyword?(keyword)
|
47
|
+
HTML_VOID_ELEMENT_KEYWORDS.include?(keyword.to_s)
|
48
|
+
end
|
49
|
+
alias void_keyword? html_void_keyword?
|
50
|
+
|
42
51
|
# NOTE: Avoid using this method until we start supporting ElementProxy subclasses
|
43
52
|
# in which case, we must cache them to avoid the slow performance of element_type
|
44
53
|
# Factory Method that translates a Glimmer DSL keyword into a ElementProxy object
|
@@ -85,8 +94,8 @@ module Glimmer
|
|
85
94
|
value = value.to_s.sub('"', '"').sub("'", ''')
|
86
95
|
output += " #{attribute}=\"#{value}\""
|
87
96
|
end
|
88
|
-
if
|
89
|
-
"<#{element}#{attributes}
|
97
|
+
if html_void_keyword?(element)
|
98
|
+
"<#{element}#{attributes}>"
|
90
99
|
else
|
91
100
|
"<#{element}#{attributes}>#{content}</#{element}>"
|
92
101
|
end
|
@@ -103,8 +112,8 @@ module Glimmer
|
|
103
112
|
Event = Struct.new(:widget, keyword_init: true)
|
104
113
|
|
105
114
|
HTML_ELEMENT_KEYWORDS = [
|
106
|
-
"a", "abbr", "acronym", "address", "applet", "
|
107
|
-
"
|
115
|
+
"a", "abbr", "acronym", "address", "applet", "article", "aside", "audio",
|
116
|
+
"basefont", "bdi", "bdo", "bgsound", "big", "blink", "blockquote", "body",
|
108
117
|
"button", "canvas", "caption", "center", "cite", "code", "col", "colgroup", "data",
|
109
118
|
"datalist", "dd", "decorator", "details", "dfn", "dir", "div", "dl", "dt",
|
110
119
|
"element", "embed", "fieldset", "figcaption", "figure", "font", "footer", "form", "frame",
|
@@ -132,6 +141,11 @@ module Glimmer
|
|
132
141
|
|
133
142
|
ELEMENT_KEYWORDS = HTML_ELEMENT_KEYWORDS + SVG_ELEMENT_KEYWORDS
|
134
143
|
|
144
|
+
HTML_VOID_ELEMENT_KEYWORDS = %w[
|
145
|
+
area base br col embed hr img input link meta param source track wbr
|
146
|
+
keygen menuitem frame
|
147
|
+
]
|
148
|
+
|
135
149
|
# title is a special attribute because it matches an element tag name (needs special treatment)
|
136
150
|
HTML_ELEMENT_SPECIAL_ATTRIBUTES = ['title']
|
137
151
|
|
@@ -225,6 +239,11 @@ module Glimmer
|
|
225
239
|
ElementProxy.svg_keyword_supported?(keyword)
|
226
240
|
end
|
227
241
|
|
242
|
+
def html_void?
|
243
|
+
ElementProxy.html_void_keyword?(keyword)
|
244
|
+
end
|
245
|
+
alias void? html_void?
|
246
|
+
|
228
247
|
def remove
|
229
248
|
return if @removed
|
230
249
|
on_remove_listeners = listeners_for('on_remove').dup
|
@@ -1048,3 +1067,4 @@ module Glimmer
|
|
1048
1067
|
end
|
1049
1068
|
|
1050
1069
|
require 'glimmer/dsl/web/element_expression'
|
1070
|
+
require 'glimmer/web/formatting_element_proxy'
|
@@ -30,12 +30,16 @@ module Glimmer
|
|
30
30
|
include Glimmer
|
31
31
|
|
32
32
|
def keyword_supported?(keyword, parent: nil)
|
33
|
+
# TODO do we need to worry about the parent of the parent being a p tag?
|
33
34
|
keyword = keyword.to_s
|
34
|
-
(
|
35
|
-
|
36
|
-
|
37
|
-
(
|
38
|
-
|
35
|
+
parent_keyword = parent.is_a?(Component) ? parent.markup_root&.keyword : parent&.keyword
|
36
|
+
|
37
|
+
parent_keyword == 'p' &&
|
38
|
+
(
|
39
|
+
FORMATTING_ELEMENT_KEYWORDS.include?(keyword) ||
|
40
|
+
(keyword == 'span') ||
|
41
|
+
(keyword == 'a')
|
42
|
+
)
|
39
43
|
end
|
40
44
|
|
41
45
|
def format(keyword, *args, &block)
|