active_html_tags 0.1.0 → 0.1.1

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: 20be1d0b49a3501924cc532bce80310d2f3f2cbd9815ebdaf4c513fbb14bb6a4
4
- data.tar.gz: 87cc98938f77d8188c7a6ccf6d20a98004c50f920913a884b8698cfb0f422a77
3
+ metadata.gz: 996f4a1573bb1b940aee11ebedaf479b79674c9e19a6e54b9f5d24ac32350987
4
+ data.tar.gz: c04362531a5c572492d206c29ef807c2c3d7c50507e684c97f1613f8617e9064
5
5
  SHA512:
6
- metadata.gz: 24ea23e08946c99c4f51ee570f5887487ca3a14819d36dee12bc04ebd619b2ee68a53c3f0c708f84d27b81de92bbd9d56332e556d7d1b5f6f452e5e0f4fd59e4
7
- data.tar.gz: 42aaf129a568fa6ed1fbd58771410e895a9d9384b68ab342929156a3b6f0455acf558da27b592ea152100336c475667f6a9ae509187071caed14ea3fc4f2bdef
6
+ metadata.gz: f2198a77d37b80e3f7524d84c1de48920b5b948f91bf4ad02a788de8fb14217e3fc6e4149a7f121ffbdd16135fd28c422466ec65fa87d60d6b999eb84f0589b4
7
+ data.tar.gz: db12531def728597a95350728f833e73432995d0baa731bf20e82b79315547e8b6c2cf353c00934b48077e4b576cf2dc621f715bdbbf24ab041c563d0d17539e
data/MIT-LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright 2021 Fabian
1
+ Copyright 2021 Fabian Stillhart
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining
4
4
  a copy of this software and associated documentation files (the
data/README.md CHANGED
@@ -14,13 +14,16 @@ Now you should be able to use any html tag as a ruby method in your views.
14
14
 
15
15
  # Usage
16
16
 
17
- ActiveHtmlTags is a helper to use any kind of HTML tag as a direct method instead of passing it to `content_tag`. At the same time it allows for multiple arguments to be given and for smarter options.
17
+ ActiveHtmlTags is a helper to use any kind of HTML tag as a direct method instead of passing it to `content_tag #` or `tag.#`. At the same time it allows for multiple arguments to be given and for smarter options.
18
18
 
19
19
  ```ruby
20
- # In any view using ApplicationHelper, for example in app/views/___/___.html.erb or app/views/layouts/application.html.erb
20
+ # In any view using ApplicationHelper
21
+ # for example in app/views/___/___.html.erb
22
+ # app/views/layouts/application.html.erb
21
23
 
22
24
  <%= h1 "This is pretty awesome" %>
23
- <%= content_tag :h1, "compared to this" %>
25
+ <%= tag.h1, "compared to this" %>
26
+ <%= content_tag :h1, "or this" %>
24
27
  ```
25
28
 
26
29
  The name mappings from html tags to method names are 1:1. Therefore you can create constructs like these:
@@ -40,15 +43,30 @@ The name mappings from html tags to method names are 1:1. Therefore you can crea
40
43
  <% end %>
41
44
  ```
42
45
 
43
- A list of all HTML available and usable tags can be found on [w3schools - TAGs](https://www.w3schools.com/TAGs/)
46
+ A list of all HTML available and usable tags can be found on [w3schools - TAGs](https://www.w3schools.com/TAGs/).
47
+
48
+ Currently all these tags are supported:
49
+ ```
50
+ a, abbr, acronym, address, applet, area, article, aside, audio, b, base, basefont,
51
+ bb, bdo, big, blockquote, body, button, canvas, caption, center, cite, code, col,
52
+ colgroup, command, datagrid, datalist, dd, del, details, dfn, dialog, dir, div, dl,
53
+ dt, em, embed, eventsource, fieldset, figcaption, figure, font, footer, form, frame,
54
+ frameset, h1, h2, h3, h4, h5, h6, head, header, hgroup, html, i, iframe, img, input,
55
+ ins, isindex, kbd, keygen, label, legend, li, link, map, mark, menu, meta, meter, nav,
56
+ noframes, noscript, object, ol, optgroup, option, output, p, param, pre, progress, q,
57
+ rp, rt, ruby, s, samp, script, section, select, small, source, span, strike, strong,
58
+ style, sub, sup, table, tbody, td, textarea, tfoot, th, thead, time, title, tr, track,
59
+ tt, u, ul, var, video, wbr, hr, br
60
+ ```
44
61
 
45
62
  ### Unlimited arguments
46
63
 
47
64
  Additionally the `content_tag` method signature has been improved slightly. Now it supports a list of arguments
48
65
  ```ruby
49
- <%= h1 "This is pretty awesome", "because you can add as much as you want", small("and what you want") %>
66
+ <%= h1 "You can add as much", "as you want", small("and what you want") %>
50
67
  vs
51
- <%= content_tag :h1, safe_join(["this is", "not very", "sexy", content_tag(:small, "or readable")], " ") %>
68
+ <%= tag.span :h1, safe_join(["this is not very", "sexy", content_tag(:small, "or readable")], " ") %>
69
+ <%= content_tag :h1, safe_join(["this is not very", "sexy", content_tag(:small, "or readable")], " ") %>
52
70
  ```
53
71
 
54
72
  ### Advanced options for style
@@ -56,16 +74,16 @@ vs
56
74
  Have you ever wondered why this happens with css? Now you don't have run into this anymore, arrays and hashes are first class citizens in ActiveHtmlTags.
57
75
 
58
76
  ```ruby
59
- <%= span "this text is actually green", style: {color: :green}%>
77
+ <%= span "this text is actually green", style: {color: :green} %>
60
78
  # <span style="color: green">this text is actually green</span>
61
79
  vs
62
- <%= content_tag :span, "this text is sadly not green", style: {color: :green}%>
63
- # <span style="{color: :green}">this text is sadly not green</span>
80
+ <%= content_tag :span, "this text is sadly not green", style: {color: :green} %>
81
+ # <span style="color green">this text is sadly not green</span>
64
82
  ```
65
83
 
66
84
  This allows for more complex scenarios
67
85
  ```ruby
68
- <%= base_style = {"background-color" => "blue"} # Place this somewhere nicely to allow for compositon. %>
86
+ <%= base_style = {"background-color" => "blue"} # Place this logic somewhere nicely %>
69
87
 
70
88
  <%= span "this text is actually green on blue", style: base_style.merge({color: :green}) %>
71
89
  # <span style="background-color: blue ; color: green">this text is actually green on blue</span>
@@ -138,5 +156,11 @@ $ gem install active_html_tags
138
156
 
139
157
  Feel free to create a merge request in case of bugs, features and more.
140
158
 
159
+ ### Test
160
+
161
+ ```
162
+ bundle exec rake test
163
+ ```
164
+
141
165
  ## License
142
166
  The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
data/Rakefile CHANGED
@@ -1,8 +1,10 @@
1
- require "bundler/setup"
1
+ # frozen_string_literal: true
2
2
 
3
- require "bundler/gem_tasks"
3
+ require 'bundler/setup'
4
4
 
5
- require "rake/testtask"
5
+ require 'bundler/gem_tasks'
6
+
7
+ require 'rake/testtask'
6
8
 
7
9
  Rake::TestTask.new(:test) do |t|
8
10
  t.libs << 'test'
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module ActiveHtmlTags
2
4
  class Railtie < ::Rails::Railtie
3
5
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module ActiveHtmlTags
2
- VERSION = '0.1.0'
4
+ VERSION = '0.1.1'
3
5
  end
@@ -1,5 +1,7 @@
1
- require "active_html_tags/version"
2
- require "active_html_tags/railtie"
1
+ # frozen_string_literal: true
2
+
3
+ require 'active_html_tags/version'
4
+ require 'active_html_tags/railtie'
3
5
 
4
6
  module ActiveHtmlTags
5
7
  HTML_TAGS = [
@@ -125,14 +127,14 @@ module ActiveHtmlTags
125
127
  :video,
126
128
  :wbr,
127
129
  :hr,
128
- :br,
130
+ :br
129
131
  # :"!--...--",
130
132
  # :"!doctype",
131
- ]
133
+ ].freeze
132
134
 
133
135
  HTML_ATTRIBUTES = {
134
136
  accept: :default,
135
- #accept-charset: :default,
137
+ # accept-charset: :default,
136
138
  accept_charset: :default,
137
139
  accesskey: :default,
138
140
  action: :default,
@@ -156,7 +158,7 @@ module ActiveHtmlTags
156
158
  controls: :default,
157
159
  coords: :default,
158
160
  data: :default,
159
- #data-*: :default,
161
+ # data-*: :default,
160
162
  datetime: :default,
161
163
  default: :default,
162
164
  defer: :js,
@@ -175,7 +177,7 @@ module ActiveHtmlTags
175
177
  high: :default,
176
178
  href: :default,
177
179
  hreflang: :default,
178
- #http-equiv: :default,
180
+ # http-equiv: :default,
179
181
  http_equiv: :default,
180
182
  id: :default,
181
183
  ismap: :default,
@@ -299,37 +301,37 @@ module ActiveHtmlTags
299
301
  usemap: :default,
300
302
  value: :default,
301
303
  width: :default,
302
- wrap: :default,
303
- }
304
+ wrap: :default
305
+ }.freeze
304
306
 
305
307
  HTML_TAGS.each do |tagname|
306
- define_method tagname do |*args, safe_join_with: " ", **opts, &blk|
307
- opts.each do |key,value|
308
+ define_method tagname do |*args, safe_join_with: ' ', **opts, &blk|
309
+ opts.each do |key, _value|
308
310
  case HTML_ATTRIBUTES[key]
309
311
  when :default
310
312
  case opts[key]
311
- when nil, String #fastpath
313
+ when nil, String # fastpath
312
314
  when Hash
313
- opts = opts.merge(key => safe_join(opts[key].values, " "))
315
+ opts = opts.merge(key => safe_join(opts[key].values, ' '))
314
316
  when Array
315
- opts = opts.merge(key => safe_join(opts[key].map(&:to_s), " "))
317
+ opts = opts.merge(key => safe_join(opts[key].map(&:to_s), ' '))
316
318
  end
317
319
  when :style
318
320
  case opts[:style]
319
- when nil, String #fastpath
321
+ when nil, String # fastpath
320
322
  when Hash
321
- opts = opts.merge(style: safe_join(opts[:style].map {|key,value| safe_join([key, value], ": ")}, " ; "))
323
+ opts = opts.merge(style: safe_join(opts[:style].map { |key, value| safe_join([key, value], ': ') }, ' ; '))
322
324
  when Array
323
- opts = opts.merge(style: safe_join(opts[:style].map(&:to_s), " ; "))
325
+ opts = opts.merge(style: safe_join(opts[:style].map(&:to_s), ' ; '))
324
326
  end
325
327
  when :js
326
328
  case opts[key]
327
329
  when nil, String # fastpath
328
330
  when Hash
329
- opts = opts.merge(key => safe_join(opts[key].values.flatten, " ; "))
331
+ opts = opts.merge(key => safe_join(opts[key].values.flatten, ' ; '))
330
332
  when Array
331
- opts = opts.merge(key => safe_join(opts[key].flatten.map(&:to_s), " ; "))
332
- end
333
+ opts = opts.merge(key => safe_join(opts[key].flatten.map(&:to_s), ' ; '))
334
+ end
333
335
  end
334
336
  end
335
337
  content_tag(tagname, safe_join(args.flatten, safe_join_with), **opts, &blk)
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  # desc "Explaining what the task does"
2
3
  # task :active_html_tags do
3
4
  # # Task goes here
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: active_html_tags
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Fabian stillhart
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-10-26 00:00:00.000000000 Z
11
+ date: 2023-10-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -16,7 +16,7 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '6.1'
19
+ version: '7'
20
20
  - - ">="
21
21
  - !ruby/object:Gem::Version
22
22
  version: 6.1.4.1
@@ -26,13 +26,12 @@ dependencies:
26
26
  requirements:
27
27
  - - "~>"
28
28
  - !ruby/object:Gem::Version
29
- version: '6.1'
29
+ version: '7'
30
30
  - - ">="
31
31
  - !ruby/object:Gem::Version
32
32
  version: 6.1.4.1
33
- description: Annoyed to write content_tag(:span, 'LOL')? Just use the new helpers
34
- as follows span('lol') to avoid writing to much code while having the safety of
35
- rails.
33
+ description: Annoyed to write tag.span('LOL')? Just use the new helpers as follows
34
+ span('lol') to avoid writing to much code while having the safety of rails.
36
35
  email:
37
36
  - fabian_stillhart@hotmail.com
38
37
  executables: []
@@ -69,7 +68,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
69
68
  - !ruby/object:Gem::Version
70
69
  version: '0'
71
70
  requirements: []
72
- rubygems_version: 3.2.3
71
+ rubygems_version: 3.4.10
73
72
  signing_key:
74
73
  specification_version: 4
75
74
  summary: A simple helper to bring content_tag to the next level