dhtml 0.1.3 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +10 -11
- data/Gemfile +0 -0
- data/Gemfile.lock +0 -0
- data/LICENSE.txt +0 -0
- data/README.md +0 -0
- data/dhtml.gemspec +0 -0
- data/lib/dhtml.rb +0 -0
- data/lib/dhtml/document.rb +22 -0
- data/lib/dhtml/opal.rb +0 -0
- data/lib/dhtml/version.rb +1 -1
- 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: 9fe9a81232d087f78f919f95b27cdffc5ccefd5a4134dad6ed21cce7e3856265
|
4
|
+
data.tar.gz: 4db4671909efeb3a9a149b56f8d8cc72c606fc2babc81a3ace13df126a1a7a29
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9a8daa8a23422a54a929ba5350a60795cd8b9b863fc59f71de0e9a57d4f2b299725d632b07d3c8f4d3bd9c1cefa50a6cde73a1a414bad7bf21cc5de7ee050755
|
7
|
+
data.tar.gz: 9943ffda42a1c42f04ee12338fd26fcb9e5725757292646107241457033810cef7383d2336fffff44dc7edbdfeb2fe7c3782b5c8f55f5e72312cd5663bc05914
|
data/CHANGELOG.md
CHANGED
@@ -5,21 +5,20 @@ The format is based on [Keep a Changelog], and this project adheres to [Semantic
|
|
5
5
|
|
6
6
|
## [Unreleased]
|
7
7
|
|
8
|
-
## [0.1.
|
9
|
-
### Fixed
|
10
|
-
- The gemspec no longer uses absolute paths for the sources.
|
11
|
-
|
12
|
-
## [0.1.2] - 2021-05-10
|
8
|
+
## [0.1.4] - 2021-05-11
|
13
9
|
### Added
|
14
|
-
- `
|
10
|
+
- `pretty_html` method that formats the document in a way presentable to a human.
|
15
11
|
|
16
|
-
|
17
|
-
-
|
12
|
+
### Fixed
|
13
|
+
- `write_html_tag` and `write_html_element` return the number of bytes written.
|
18
14
|
|
15
|
+
## [0.1.3] - 2021-05-10
|
16
|
+
- Initial release
|
17
|
+
- Versions prior to this were yanked. The gems were packaged with absolute paths by mistake.
|
19
18
|
|
20
|
-
[Unreleased]: https://github.com/hi5dev/dhtml/compare/v0.1.
|
21
|
-
[0.1.
|
22
|
-
[0.1.
|
19
|
+
[Unreleased]: https://github.com/hi5dev/dhtml/compare/v0.1.4...HEAD
|
20
|
+
[0.1.4]: https://github.com/hi5dev/dhtml/compare/v0.1.3..v0.1.4
|
21
|
+
[0.1.3]: https://github.com/hi5dev/dhtml/releases/tag/v0.1.3
|
23
22
|
|
24
23
|
[Keep a Changelog]: https://keepachangelog.com/en/1.0.0/
|
25
24
|
[Semantic Versioning]: https://semver.org/spec/v2.0.0.html
|
data/Gemfile
CHANGED
File without changes
|
data/Gemfile.lock
CHANGED
File without changes
|
data/LICENSE.txt
CHANGED
File without changes
|
data/README.md
CHANGED
File without changes
|
data/dhtml.gemspec
CHANGED
File without changes
|
data/lib/dhtml.rb
CHANGED
File without changes
|
data/lib/dhtml/document.rb
CHANGED
@@ -97,6 +97,18 @@ module DHTML
|
|
97
97
|
|
98
98
|
alias_method :h, :html_escape
|
99
99
|
|
100
|
+
# Reads and formats the document in a way presentable to a human.
|
101
|
+
#
|
102
|
+
# @note Not available to Opal.
|
103
|
+
# @param [String] indent string.
|
104
|
+
# @return [String]
|
105
|
+
# @since 0.1.4
|
106
|
+
def pretty_html(indent: ' ' * 2)
|
107
|
+
require 'cgi' unless defined?(CGI)
|
108
|
+
|
109
|
+
CGI.pretty(read_html, indent)
|
110
|
+
end if RUBY_ENGINE != 'opal'
|
111
|
+
|
100
112
|
# Reads the entire HTML document.
|
101
113
|
#
|
102
114
|
# @return [String]
|
@@ -121,10 +133,14 @@ module DHTML
|
|
121
133
|
# @return [Integer] Number of bytes written to the stream.
|
122
134
|
# @since 0.1.0
|
123
135
|
def write_html_element(tag, attributes = {})
|
136
|
+
length = document.length
|
137
|
+
|
124
138
|
document << '<'
|
125
139
|
document << tag
|
126
140
|
document << " #{html_attributes(attributes)}" unless attributes.empty?
|
127
141
|
document << '>'
|
142
|
+
|
143
|
+
document.length - length
|
128
144
|
end
|
129
145
|
|
130
146
|
# Write a tag to the HTML document.
|
@@ -142,6 +158,9 @@ module DHTML
|
|
142
158
|
tag = tag.to_s
|
143
159
|
tag = tag[1..-1] if tag[0] == '_'
|
144
160
|
|
161
|
+
# Used to calculate the number of bytes written for the return value.
|
162
|
+
length = document.length
|
163
|
+
|
145
164
|
# Opening tag with its HTML attributes - e.g. <div id="main">
|
146
165
|
write_html_element(tag, attributes)
|
147
166
|
|
@@ -153,6 +172,9 @@ module DHTML
|
|
153
172
|
|
154
173
|
# Close the tag when necessary.
|
155
174
|
document.write("</#{tag}>") if content.is_a?(String) || block_given? || !void?(tag.to_sym)
|
175
|
+
|
176
|
+
# Total number of bytes written by this method.
|
177
|
+
document.length - length
|
156
178
|
end
|
157
179
|
end
|
158
180
|
end
|
data/lib/dhtml/opal.rb
CHANGED
File without changes
|
data/lib/dhtml/version.rb
CHANGED