fun_html 0.2.0 → 0.3.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3e5e644d2ee9775409d54d3340ee692e557614bb1e85ef0c290317c0d00e9432
4
- data.tar.gz: 4792b3bf1361a392a59221c43a937ce1922108d09b6f799a6c5a74466c41e760
3
+ metadata.gz: 4fe70a0317730c02b34d0727a50c3cec42e8e0125a9da574ed0626b3e8f64432
4
+ data.tar.gz: 92a2bdc05ab5fdc34db3d6c284a34237f0218e6abc506d226351ac550805966f
5
5
  SHA512:
6
- metadata.gz: 808d8bb9950923c28e12b81c39d7be030aa2cf315d73e4b28efe157398aeaaacc349983bb785e167e59c6cad284656f6e310fff215d8022e15eebf89c1f51b81
7
- data.tar.gz: a75a3249ea3253801467b1324b6da56c090ca919ea74309a900f80635d7a01dadfeab966844e98a20305a4b3cd0f96621ac929157309df861fddc3e511c424d4
6
+ metadata.gz: cf86a98a685339cbcad38e55c9f3ce8dfe05e109c1acd42c470038a0ffa2211e6008ad690abe014e7173ce89dfa085e0be1e1822ba5d9d1fc09c93b8c8e6d70d
7
+ data.tar.gz: f942f6395d3f5ef8f00db4a26c1a615d4c210502b20b08c62e9c4c1162a56e1da721df1d30178ae151cab8ea6e8a8055546ca0c70884254d9ea3dd16c995a715
@@ -60,6 +60,16 @@ module FunHtml
60
60
  write(' class="', value)
61
61
  end
62
62
 
63
+ # classes takes a hash of class names and boolean values
64
+ # only the names with a true value will be printed
65
+ # classes({'a' => true, 'b' => false, 'c' => true}) -> ' class="a c"'
66
+ def classes(list)
67
+ klass list.select { |_k, v| v == true }.keys.join(' ')
68
+ end
69
+
70
+ # alias so klass has classes
71
+ def klasses(list) = classes(list)
72
+
63
73
  # Merge another Attribute to create a new, combined, Attribute.
64
74
  def merge(other)
65
75
  self.class.new(@__buffer.merge(other.instance_variable_get(:@__buffer)))
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module FunHtml
4
- VERSION = '0.2.0'
4
+ VERSION = '0.3.0'
5
5
  end
data/rbi/fun_html.rbi CHANGED
@@ -76,6 +76,12 @@ module FunHtml
76
76
  sig { params(attr: T.nilable(FunHtml::Attribute)).returns(String) }
77
77
  def self.to_html(attr); end
78
78
 
79
+ sig { params(list: T::Hash[String, T::Boolean]).returns(FunHtml::Attribute) }
80
+ def classes(list); end
81
+
82
+ sig { params(list: T::Hash[String, T::Boolean]).returns(FunHtml::Attribute) }
83
+ def klasses(list); end
84
+
79
85
  sig { params(other: FunHtml::Attribute).returns(FunHtml::Attribute) }
80
86
  def merge(other); end
81
87
 
data/rbi/fun_html.rbx CHANGED
@@ -76,6 +76,12 @@ module FunHtml
76
76
  sig { params(attr: T.nilable(FunHtml::Attribute)).returns(String) }
77
77
  def self.to_html(attr); end
78
78
 
79
+ sig { params(list: T::Hash[String, T::Boolean]).returns(FunHtml::Attribute) }
80
+ def classes(list); end
81
+
82
+ sig { params(list: T::Hash[String, T::Boolean]).returns(FunHtml::Attribute) }
83
+ def klasses(list); end
84
+
79
85
  sig { params(other: FunHtml::Attribute).returns(FunHtml::Attribute) }
80
86
  def merge(other); end
81
87
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fun_html
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - John Weir
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2025-02-14 00:00:00.000000000 Z
11
+ date: 2025-03-05 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: It probably is not much fun, despite the name.
14
14
  email: