html_tags 0.1.120

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of html_tags might be problematic. Click here for more details.

Files changed (86) hide show
  1. checksums.yaml +7 -0
  2. data/README.md +110 -0
  3. data/USAGE.md +17 -0
  4. data/doc/README.gen +69 -0
  5. data/html_tags.gemspec +53 -0
  6. data/lib/html_tags/array_registered_html_tags.rb +125 -0
  7. data/lib/html_tags/autoinclude.rb +2 -0
  8. data/lib/html_tags/autoinclude_base_module.rb +7 -0
  9. data/lib/html_tags/base/README.md +3 -0
  10. data/lib/html_tags/base/base.rb +11 -0
  11. data/lib/html_tags/base/base_module.rb +224 -0
  12. data/lib/html_tags/base/prototype.rb +19 -0
  13. data/lib/html_tags/checks.rb +58 -0
  14. data/lib/html_tags/closing_tag/closing_tag.rb +76 -0
  15. data/lib/html_tags/constants/array_strip_newlines.rb +14 -0
  16. data/lib/html_tags/constants/misc.rb +21 -0
  17. data/lib/html_tags/constants.rb +26 -0
  18. data/lib/html_tags/html_closing_tags.rb +36 -0
  19. data/lib/html_tags/html_comment.rb +29 -0
  20. data/lib/html_tags/html_tags.rb +131 -0
  21. data/lib/html_tags/html_tags_constants.rb +14 -0
  22. data/lib/html_tags/individual_tags/a.rb +524 -0
  23. data/lib/html_tags/individual_tags/abbr.rb +44 -0
  24. data/lib/html_tags/individual_tags/audio.rb +32 -0
  25. data/lib/html_tags/individual_tags/b.rb +22 -0
  26. data/lib/html_tags/individual_tags/blockquote.rb +19 -0
  27. data/lib/html_tags/individual_tags/body.rb +19 -0
  28. data/lib/html_tags/individual_tags/br.rb +28 -0
  29. data/lib/html_tags/individual_tags/button.rb +30 -0
  30. data/lib/html_tags/individual_tags/canvas.rb +19 -0
  31. data/lib/html_tags/individual_tags/details.rb +69 -0
  32. data/lib/html_tags/individual_tags/div.rb +51 -0
  33. data/lib/html_tags/individual_tags/figure.rb +39 -0
  34. data/lib/html_tags/individual_tags/footer.rb +26 -0
  35. data/lib/html_tags/individual_tags/form.rb +93 -0
  36. data/lib/html_tags/individual_tags/h1.rb +36 -0
  37. data/lib/html_tags/individual_tags/h2.rb +42 -0
  38. data/lib/html_tags/individual_tags/h3.rb +73 -0
  39. data/lib/html_tags/individual_tags/h4.rb +36 -0
  40. data/lib/html_tags/individual_tags/h5.rb +36 -0
  41. data/lib/html_tags/individual_tags/h6.rb +40 -0
  42. data/lib/html_tags/individual_tags/head.rb +36 -0
  43. data/lib/html_tags/individual_tags/header.rb +29 -0
  44. data/lib/html_tags/individual_tags/html.rb +61 -0
  45. data/lib/html_tags/individual_tags/i.rb +14 -0
  46. data/lib/html_tags/individual_tags/img.rb +135 -0
  47. data/lib/html_tags/individual_tags/input.rb +32 -0
  48. data/lib/html_tags/individual_tags/label.rb +43 -0
  49. data/lib/html_tags/individual_tags/legend.rb +14 -0
  50. data/lib/html_tags/individual_tags/li.rb +44 -0
  51. data/lib/html_tags/individual_tags/main.rb +29 -0
  52. data/lib/html_tags/individual_tags/nav.rb +14 -0
  53. data/lib/html_tags/individual_tags/object.rb +18 -0
  54. data/lib/html_tags/individual_tags/ol.rb +50 -0
  55. data/lib/html_tags/individual_tags/p.rb +50 -0
  56. data/lib/html_tags/individual_tags/pre.rb +16 -0
  57. data/lib/html_tags/individual_tags/span.rb +60 -0
  58. data/lib/html_tags/individual_tags/strong.rb +17 -0
  59. data/lib/html_tags/individual_tags/style.rb +29 -0
  60. data/lib/html_tags/individual_tags/table.rb +33 -0
  61. data/lib/html_tags/individual_tags/tbody.rb +19 -0
  62. data/lib/html_tags/individual_tags/td.rb +24 -0
  63. data/lib/html_tags/individual_tags/textarea.rb +46 -0
  64. data/lib/html_tags/individual_tags/th.rb +14 -0
  65. data/lib/html_tags/individual_tags/thead.rb +14 -0
  66. data/lib/html_tags/individual_tags/title.rb +18 -0
  67. data/lib/html_tags/individual_tags/tr.rb +20 -0
  68. data/lib/html_tags/individual_tags/ul.rb +23 -0
  69. data/lib/html_tags/individual_tags/video.rb +54 -0
  70. data/lib/html_tags/module.rb +5 -0
  71. data/lib/html_tags/opening_tag/opening_tag.rb +288 -0
  72. data/lib/html_tags/project/project_base_directory.rb +23 -0
  73. data/lib/html_tags/requires/require_the_html_tags_project.rb +9 -0
  74. data/lib/html_tags/requires/require_the_img_tag.rb +7 -0
  75. data/lib/html_tags/shared.rb +23 -0
  76. data/lib/html_tags/stag.rb +54 -0
  77. data/lib/html_tags/toplevel_methods/add.rb +22 -0
  78. data/lib/html_tags/toplevel_methods/full_output.rb +33 -0
  79. data/lib/html_tags/toplevel_methods/newline_or_empty.rb +21 -0
  80. data/lib/html_tags/toplevel_methods/strip_newlines.rb +27 -0
  81. data/lib/html_tags/version/version.rb +17 -0
  82. data/lib/html_tags/yaml/valid_tags_in_a_head_tag.yml +16 -0
  83. data/lib/html_tags.rb +5 -0
  84. data/test/testing_html_tags.rb +158 -0
  85. data/test/testing_the_a_tag.rb +113 -0
  86. metadata +141 -0
@@ -0,0 +1,29 @@
1
+ #!/usr/bin/ruby -w
2
+ # Encoding: UTF-8
3
+ # frozen_string_literal: true
4
+ # =========================================================================== #
5
+ module HtmlTags
6
+
7
+ # ========================================================================= #
8
+ # === header
9
+ #
10
+ # Usage example:
11
+ #
12
+ # HtmlTags.header('<h1>APP NAME</h1><nav></nav>') => '<header><h1>APP NAME</h1><nav></nav></header>'
13
+ #
14
+ # ========================================================================= #
15
+ def header(
16
+ i = '', css_class = '', the_id = '', css_style = '', &block
17
+ )
18
+ content = i.to_s
19
+ if block_given?
20
+ content = content.to_s+yield.to_s
21
+ end
22
+ return HtmlTags.add(
23
+ opening_tag(__method__, css_class, the_id, css_style)+
24
+ content+
25
+ close(__method__)
26
+ )
27
+ end
28
+
29
+ end
@@ -0,0 +1,61 @@
1
+ #!/usr/bin/ruby -w
2
+ # Encoding: UTF-8
3
+ # frozen_string_literal: true
4
+ # =========================================================================== #
5
+ module HtmlTags
6
+
7
+ # ========================================================================= #
8
+ # === html
9
+ #
10
+ # A <html> tag in HTML5 may have some attributes such as:
11
+ #
12
+ # <html lang="en">
13
+ #
14
+ # See http://www.w3schools.com/tags/ref_language_codes.asp for more
15
+ # information pertaining to the <html> tag.
16
+ #
17
+ # For now, we will use lang="en" all the time.
18
+ #
19
+ # To test this standalone, try:
20
+ #
21
+ # HtmlTags.html
22
+ #
23
+ # ========================================================================= #
24
+ def html(
25
+ i = '',
26
+ css_class = '',
27
+ the_id = '',
28
+ css_style = '',
29
+ &block
30
+ )
31
+ opening = HtmlTags.open_html # Delegate to the method below.
32
+ _ = ''.dup
33
+ if block_given?
34
+ yielded = yield
35
+ case yielded
36
+ when :use_unicode_as_encoding
37
+ opening << "<meta charset=\"UTF-8\">\n"
38
+ else
39
+ _ << yielded
40
+ end
41
+ end
42
+ return HtmlTags.add(
43
+ opening+
44
+ i.to_s+
45
+ _.to_s+
46
+ close(__method__)
47
+ )
48
+ end
49
+
50
+ # ========================================================================= #
51
+ # === HtmlTags.open_html
52
+ #
53
+ # We will automatically append lang="en" to the tag.
54
+ # ========================================================================= #
55
+ def self.open_html
56
+ opening = opening_tag(:html)
57
+ opening[-2,0] = ' lang="en"'
58
+ opening
59
+ end
60
+
61
+ end
@@ -0,0 +1,14 @@
1
+ module HtmlTags
2
+
3
+ # ========================================================================= #
4
+ # === i
5
+ # ========================================================================= #
6
+ def i(i = '', css_class = '', the_id = '', css_style = '')
7
+ return HtmlTags.add(
8
+ opening_tag(__method__, css_class, the_id, css_style)+
9
+ i.to_s+
10
+ close(__method__)
11
+ )
12
+ end
13
+
14
+ end
@@ -0,0 +1,135 @@
1
+ #!/usr/bin/ruby -w
2
+ # Encoding: UTF-8
3
+ # frozen_string_literal: true
4
+ # =========================================================================== #
5
+ # require 'html_tags/individual_tags/img.rb'
6
+ # =========================================================================== #
7
+ module HtmlTags
8
+
9
+ require 'html_tags/opening_tag/opening_tag.rb'
10
+ require 'html_tags/toplevel_methods/add.rb'
11
+ require 'html_tags/toplevel_methods/newline_or_empty.rb'
12
+
13
+ # ========================================================================= #
14
+ # === HtmlTags.img
15
+ #
16
+ # The img() method creates an <img> tag.
17
+ #
18
+ # Documentation can be found at:
19
+ #
20
+ # https://www.w3schools.com/tags/tag_img.asp
21
+ # https://developer.mozilla.org/en-US/docs/Web/HTML/Element/img
22
+ #
23
+ # The "end result" will be a String such as this here:
24
+ #
25
+ # <img src="foo.png" alt="Some image">
26
+ #
27
+ # Note that we make use of the block variant, by specifying a hash which
28
+ # has a :src attribute.
29
+ #
30
+ # If the first argument to this method is a Hash then that Hash will
31
+ # be checked for certain keys, such as :src or :css_class
32
+ #
33
+ # If the argument called the_id is a symbol such as
34
+ # :infer_the_id_from_the_filename then it will be evaluated in a
35
+ # special manner.
36
+ # ========================================================================= #
37
+ def self.img(
38
+ i = 'foo.png',
39
+ css_class = '',
40
+ the_id = '',
41
+ css_style = ''
42
+ )
43
+ # ======================================================================= #
44
+ # === Handle blocks next
45
+ # ======================================================================= #
46
+ if block_given?
47
+ yielded = yield
48
+ # ===================================================================== #
49
+ # === Handle Hashes given via block syntax next
50
+ # ===================================================================== #
51
+ if yielded.is_a? Hash
52
+ if i.is_a? String
53
+ i = { src: i } # Add this string as the :src key in that case.
54
+ i.update(yielded)
55
+ end
56
+ end
57
+ end
58
+ if i.is_a? Hash
59
+ # ===================================================================== #
60
+ # === :css_style
61
+ # ===================================================================== #
62
+ if i.has_key? :css_style
63
+ css_style = i.delete(:css_style)
64
+ end
65
+ # ===================================================================== #
66
+ # === :css_class
67
+ # ===================================================================== #
68
+ if i.has_key? :css_class
69
+ css_class = i.delete(:css_class)
70
+ end
71
+ # ===================================================================== #
72
+ # === :id
73
+ # ===================================================================== #
74
+ if i.has_key? :id
75
+ the_id = i.delete(:id)
76
+ # ===================================================================== #
77
+ # === :the_id
78
+ # ===================================================================== #
79
+ elsif i.has_key? :the_id
80
+ the_id = i.delete(:the_id)
81
+ end
82
+ # ===================================================================== #
83
+ # === :src
84
+ #
85
+ # This entry point should come last, that is, after other checks were
86
+ # already done. The reason for this is due to the deliberate
87
+ # self-assignment being done here.
88
+ # ===================================================================== #
89
+ if i.has_key? :src
90
+ i = i.delete(:src)
91
+ end
92
+ end
93
+ case the_id # case tag
94
+ # ======================================================================= #
95
+ # === :drag_infer_the_id_from_the_filename
96
+ # ======================================================================= #
97
+ when :drag_infer_the_id_from_the_filename,
98
+ :drag
99
+ the_id = 'drag_'+File.basename(i).
100
+ sub(/#{File.extname(i)}/,'')
101
+ # ======================================================================= #
102
+ # === :infer_the_id_from_the_filename
103
+ # ======================================================================= #
104
+ when :infer_the_id_from_the_filename
105
+ the_id = File.basename(i).
106
+ sub(/#{File.extname(i)}/,'')
107
+ end
108
+ return HtmlTags.add(
109
+ opening_tag(__method__, css_class, the_id, css_style) {{ src: i }}+
110
+ HtmlTags.newline_or_empty.to_s # i.to_s # Disabled adding the content. <img> tags do not have any content.
111
+ )
112
+ end
113
+
114
+ # ========================================================================= #
115
+ # === img
116
+ # ========================================================================= #
117
+ def img(
118
+ i = 'foo.png',
119
+ css_class = '',
120
+ the_id = '',
121
+ css_style = ''
122
+ )
123
+ HtmlTags.img(i, css_class, the_id, css_style)
124
+ end
125
+
126
+ end
127
+
128
+ if __FILE__ == $PROGRAM_NAME
129
+ # You could also include HtmlTags, then just use img() directly.
130
+ # include HtmlTags
131
+ puts HtmlTags.img(
132
+ "studium/MASTER.png",
133
+ css_style: 'margin-left:6px'
134
+ )
135
+ end
@@ -0,0 +1,32 @@
1
+ #!/usr/bin/ruby -w
2
+ # Encoding: UTF-8
3
+ # frozen_string_literal: true
4
+ # =========================================================================== #
5
+ module HtmlTags
6
+
7
+ # ========================================================================= #
8
+ # === input
9
+ #
10
+ # Do note that input can include complex variants, such as the
11
+ # following:
12
+ #
13
+ # input(type: :submit, value: 'Create Article')
14
+ #
15
+ # ========================================================================= #
16
+ def input(
17
+ i = '', css_class = '', the_id = '', css_style = '', &block
18
+ )
19
+ block = nil
20
+ if i.is_a? Hash
21
+ block = i.dup
22
+ i = ''
23
+ end
24
+ the_open_tag = opening_tag(
25
+ __method__, css_class, the_id, css_style
26
+ ) { block }
27
+ return HtmlTags.add(
28
+ the_open_tag.strip
29
+ )
30
+ end
31
+
32
+ end
@@ -0,0 +1,43 @@
1
+ module HtmlTags
2
+
3
+ # ========================================================================= #
4
+ # === label
5
+ #
6
+ # The html <label> tag is useful to specify text before an <input>
7
+ # field.
8
+ #
9
+ # The <label> tag defines a label for an <input> element.
10
+ #
11
+ # The <label> element does not render as anything special for the
12
+ # user. However, it provides a usability improvement for mouse
13
+ # users, because if the user clicks on the text within the <label>
14
+ # element, it toggles the control.
15
+ #
16
+ # The "for" attribute of the <label> tag should be equal to the id
17
+ # attribute of the related element to bind them together.
18
+ #
19
+ # This may be best explained through an example:
20
+ #
21
+ # <label for="male">Male</label>
22
+ # <input type="radio" name="sex" id="male" value="male">
23
+ #
24
+ # Documentation can be seen here:
25
+ # http://www.w3schools.com/tags/tag_label.asp
26
+ # ========================================================================= #
27
+ def label(
28
+ i = '',
29
+ css_class = '',
30
+ the_id = '',
31
+ css_style = ''
32
+ )
33
+ start = opening_tag(__method__, css_class, the_id, css_style)
34
+ for_label = i.to_s.downcase.strip # Right now the for-label is deduced from the input.
35
+ start[-2,0] = ' for="'+for_label+'"' # -2 because we also have a trailing newline.
36
+ return HtmlTags.add(
37
+ start+
38
+ i.to_s+
39
+ close(__method__)
40
+ )
41
+ end
42
+
43
+ end
@@ -0,0 +1,14 @@
1
+ module HtmlTags
2
+
3
+ # ========================================================================= #
4
+ # === legend
5
+ # ========================================================================= #
6
+ def legend(i = '', css_class = '', the_id = '', css_style = '')
7
+ return HtmlTags.add(
8
+ opening_tag(__method__, css_class, the_id, css_style)+
9
+ i.to_s+
10
+ close(__method__)
11
+ )
12
+ end
13
+
14
+ end
@@ -0,0 +1,44 @@
1
+ #!/usr/bin/ruby -w
2
+ # Encoding: UTF-8
3
+ # frozen_string_literal: true
4
+ # =========================================================================== #
5
+ module HtmlTags
6
+
7
+ # ========================================================================= #
8
+ # === li (li tag)
9
+ #
10
+ # This is essentially a HTML representation for the <li> tag.
11
+ #
12
+ # The first input argument to this method will constitute the content
13
+ # of said <li> tag. Note that the block form to li {} can also be
14
+ # used for content, so use whichever way you prefer.
15
+ # ========================================================================= #
16
+ def li(
17
+ i = '', # <- This is the content.
18
+ css_class = '',
19
+ the_id = '',
20
+ css_style = '',
21
+ optional_javascript = '',
22
+ &block
23
+ )
24
+ if i.is_a? Hash
25
+ if i.has_key? :css_class
26
+ css_class = i.delete(:css_class)
27
+ end
28
+ i = ''
29
+ end
30
+ i = i.to_s.dup # And avoid frozen-errors.
31
+ # ======================================================================= #
32
+ # Blocks will be assumed to be used for the first argument, `i`.
33
+ # ======================================================================= #
34
+ if block_given?
35
+ i << yield.to_s
36
+ end
37
+ return HtmlTags.add(
38
+ opening_tag(__method__, css_class, the_id, css_style, optional_javascript)+
39
+ i+
40
+ close(__method__)
41
+ )
42
+ end
43
+
44
+ end
@@ -0,0 +1,29 @@
1
+ #!/usr/bin/ruby -w
2
+ # Encoding: UTF-8
3
+ # frozen_string_literal: true
4
+ # =========================================================================== #
5
+ module HtmlTags
6
+
7
+ # ========================================================================= #
8
+ # === main
9
+ #
10
+ # Usage example:
11
+ #
12
+ # HtmlTags.main('<h1>APP NAME</h1><nav></nav>') => '<header><h1>APP NAME</h1><nav></nav></header>'
13
+ #
14
+ # ========================================================================= #
15
+ def main(
16
+ i = '', css_class = '', the_id = '', css_style = '', &block
17
+ )
18
+ content = i.to_s
19
+ if block_given?
20
+ content = content.to_s+yield.to_s
21
+ end
22
+ return HtmlTags.add(
23
+ opening_tag(__method__, css_class, the_id, css_style)+
24
+ content+
25
+ close(__method__)
26
+ )
27
+ end
28
+
29
+ end
@@ -0,0 +1,14 @@
1
+ module HtmlTags
2
+
3
+ # ========================================================================= #
4
+ # === nav
5
+ # ========================================================================= #
6
+ def nav(i = '', css_class = '', the_id = '', css_style = '')
7
+ return HtmlTags.add(
8
+ opening_tag(__method__, css_class, the_id, css_style)+
9
+ i.to_s+
10
+ close(__method__)
11
+ )
12
+ end
13
+
14
+ end
@@ -0,0 +1,18 @@
1
+ #!/usr/bin/ruby -w
2
+ # Encoding: UTF-8
3
+ # frozen_string_literal: true
4
+ # =========================================================================== #
5
+ module HtmlTags
6
+
7
+ # ========================================================================= #
8
+ # === object
9
+ # ========================================================================= #
10
+ def object(i = '', css_class = '', the_id = '', css_style = '')
11
+ return HtmlTags.add(
12
+ opening_tag(__method__, css_class, the_id, css_style)+
13
+ i.to_s+
14
+ close(__method__)
15
+ )
16
+ end
17
+
18
+ end
@@ -0,0 +1,50 @@
1
+ #!/usr/bin/ruby -w
2
+ # Encoding: UTF-8
3
+ # frozen_string_literal: true
4
+ # =========================================================================== #
5
+ module HtmlTags
6
+
7
+ # ========================================================================= #
8
+ # === ol (ol tag)
9
+ #
10
+ # This is essentially a HTML representation for the <ol> tag.
11
+ #
12
+ # The <ol> tag defines an ordered list. An ordered list can be
13
+ # either numerical or it can be alphabetical.
14
+ #
15
+ # The <li> tag can be used to define list items.
16
+ #
17
+ # Documentation for the <ol> tag can be seen here:
18
+ #
19
+ # https://www.w3schools.com/tags/tag_ol.asp
20
+ #
21
+ # ========================================================================= #
22
+ def ol(
23
+ i = '', # <- This is the content.
24
+ css_class = '',
25
+ the_id = '',
26
+ css_style = '',
27
+ optional_javascript = '',
28
+ &block
29
+ )
30
+ if i.is_a? Hash
31
+ if i.has_key? :css_class
32
+ css_class = i.delete(:css_class)
33
+ end
34
+ i = ''
35
+ end
36
+ i = i.to_s.dup # And avoid frozen-errors.
37
+ # ======================================================================= #
38
+ # Blocks will be assumed to be used for the first argument, `i`.
39
+ # ======================================================================= #
40
+ if block_given?
41
+ i << yield.to_s
42
+ end
43
+ return HtmlTags.add(
44
+ opening_tag(__method__, css_class, the_id, css_style, optional_javascript)+
45
+ i+
46
+ close(__method__)
47
+ )
48
+ end
49
+
50
+ end
@@ -0,0 +1,50 @@
1
+ #!/usr/bin/ruby -w
2
+ # Encoding: UTF-8
3
+ # frozen_string_literal: true
4
+ # =========================================================================== #
5
+ # require 'html_tags/individual_tags/p.rb'
6
+ # =========================================================================== #
7
+ module HtmlTags
8
+
9
+ # ========================================================================= #
10
+ # === HtmlTags.p
11
+ #
12
+ # This method can be used to create the html <p> tag.
13
+ # ========================================================================= #
14
+ def self.p(
15
+ i = '',
16
+ css_class = '',
17
+ the_id = '',
18
+ css_style = ''
19
+ )
20
+ if i.is_a? Hash
21
+ # ===================================================================== #
22
+ # === Handle entries such as p(css_style: 'padding:2em')
23
+ # ===================================================================== #
24
+ if i.has_key? :css_style
25
+ css_style = i.delete(:css_style)
26
+ i = '' if i.empty?
27
+ end
28
+ if i.is_a?(Hash) and i.has_key?(:css_class)
29
+ css_class = i.delete(:css_class)
30
+ i = '' if i.empty?
31
+ end
32
+ end
33
+ result = opening_tag(__method__, css_class, the_id, css_style).dup
34
+ if block_given?
35
+ result << yield.to_s
36
+ end
37
+ result << i.to_s+close(__method__).to_s
38
+ return HtmlTags.add(result)
39
+ end
40
+
41
+ # ========================================================================= #
42
+ # === p
43
+ # ========================================================================= #
44
+ def p(
45
+ i = '', css_class = '', the_id = '', css_style = ''
46
+ )
47
+ HtmlTags.p(i, css_class, the_id, css_style)
48
+ end
49
+
50
+ end
@@ -0,0 +1,16 @@
1
+ module HtmlTags
2
+
3
+ # ========================================================================= #
4
+ # === pre
5
+ # ========================================================================= #
6
+ def pre(
7
+ i = '', css_class = '', the_id = '', css_style = ''
8
+ )
9
+ return HtmlTags.add(
10
+ opening_tag(__method__, css_class, the_id, css_style)+
11
+ i.to_s+
12
+ close(__method__)
13
+ )
14
+ end
15
+
16
+ end
@@ -0,0 +1,60 @@
1
+ #!/usr/bin/ruby -w
2
+ # Encoding: UTF-8
3
+ # frozen_string_literal: true
4
+ # =========================================================================== #
5
+ module HtmlTags
6
+
7
+ # ========================================================================= #
8
+ # === span
9
+ #
10
+ # This method will generate HTML <span> tags.
11
+ #
12
+ # It will first invoke the method called opening_tag(), then add
13
+ # the content that was given to it (the first parameter), and then
14
+ # close the whole tag via the close() method.
15
+ #
16
+ # Do note that you can eliminate newlines by invoking the method
17
+ # in something like this, via :strip:
18
+ #
19
+ # HtmlTags.span('Hello world!','s1') { :strip }
20
+ # HtmlTags.span(i, css_class: 'bord1px', css_style: 'margin-left: 1em')
21
+ #
22
+ # ========================================================================= #
23
+ def span(
24
+ i = '',
25
+ css_class = '',
26
+ the_id = '',
27
+ css_style = '',
28
+ javascript = '',
29
+ &block
30
+ )
31
+ i = i.to_s
32
+ start_the_method = opening_tag(
33
+ __method__,
34
+ css_class,
35
+ the_id,
36
+ css_style,
37
+ javascript
38
+ )
39
+ close_the_method = close(__method__)
40
+ if block_given?
41
+ yielded = yield
42
+ case yielded
43
+ when :strip
44
+ # Unfreeze, if frozen:
45
+ i = i.dup if i.frozen?
46
+ close_the_method = close_the_method.dup if close_the_method.frozen?
47
+ start_the_method = start_the_method.dup if start_the_method.frozen?
48
+ i.strip!
49
+ close_the_method.strip!
50
+ start_the_method.strip!
51
+ end
52
+ end
53
+ return HtmlTags.add(
54
+ start_the_method+
55
+ i+
56
+ close_the_method
57
+ )
58
+ end; alias s2 span
59
+
60
+ end
@@ -0,0 +1,17 @@
1
+ module HtmlTags
2
+
3
+ # ========================================================================= #
4
+ # === strong
5
+ #
6
+ # For most purposes, this can be treated as the old (pre-html5) bold
7
+ # html tag.
8
+ # ========================================================================= #
9
+ def strong(i = '', css_class = '', the_id = '', css_style = '')
10
+ return HtmlTags.add(
11
+ opening_tag(__method__, css_class, the_id, css_style)+
12
+ i.to_s+
13
+ close(__method__)
14
+ )
15
+ end
16
+
17
+ end
@@ -0,0 +1,29 @@
1
+ #!/usr/bin/ruby -w
2
+ # Encoding: UTF-8
3
+ # frozen_string_literal: true
4
+ # =========================================================================== #
5
+ module HtmlTags
6
+
7
+ # ========================================================================= #
8
+ # === style
9
+ #
10
+ # We first call the opening_tag() method, then add the content,
11
+ # and then close the whole thing again via close().
12
+ #
13
+ # This is essentially a way to add CSS style to a HTML-page.
14
+ # ========================================================================= #
15
+ def style(
16
+ i = '',
17
+ css_class = '',
18
+ the_id = '',
19
+ css_style = '',
20
+ javascript = ''
21
+ )
22
+ return HtmlTags.add(
23
+ opening_tag(__method__, css_class, the_id, css_style, javascript)+
24
+ i.to_s+
25
+ close(__method__)
26
+ )
27
+ end
28
+
29
+ end