brut 0.0.4 → 0.0.5

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: 52658877be0d3d968e4bcf7fea163aded14460e1d5027450f7e981bce2e972be
4
- data.tar.gz: 4f415cd218aeec5eb4ad1f30eb686a2b41ac3293a71a6b61635f2913c6afd6a9
3
+ metadata.gz: 7702194ca39391fce02e749d6050ff7ac0856739d4e635a562d01284eb8d2d95
4
+ data.tar.gz: b7581e5a3ae897eae7acfb200e8a40c36092992305db27f25e319807d6986882
5
5
  SHA512:
6
- metadata.gz: 49bc406aced82e963475446bedd3669133a055440bfaed9da7e6a2c58288b02717a64b4f3ffa4886bb651233d9de42956d973ccb4853235271083f19f7c8a927
7
- data.tar.gz: 8e299c68165fc48700d8d7cc85bb7d12ddaf9fa96c7227043d893d4a4a378314a97279767e34425ce729810712eae7dacaa55326452a5ba79c645fe5ab4640e6
6
+ metadata.gz: d8cb683694e8a4b1f1d35226d3cc0f60d3b4c6200c81f89a330f4efb74e359a8f31ebee40b2ad9b8264188b960bee505634092417b0e48fa8b71825d7bf01810
7
+ data.tar.gz: d5ab249e7cdb783a9698af017c8c550910b39863c26842357c422e70716e5ce940ba6150d43e621faa60b9fdeffd578d765479ad2168403c5a2e863c427e8bfe
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- brut (0.0.4)
4
+ brut (0.0.5)
5
5
  concurrent-ruby
6
6
  i18n
7
7
  irb
@@ -197,9 +197,10 @@ class Brut::FrontEnd::Component
197
197
  # @param timestamp [Time] the timestamp to format/render. Mutually exclusive with `date`.
198
198
  # @param date [Date] the date to format/render. Mutually exclusive with `timestamp`.
199
199
  # @param component_options [Hash] keyword arguments to pass to {Brut::FrontEnd::Components::Time#initialize}
200
- def time_tag(timestamp:nil,date:nil, **component_options)
200
+ # @yield See {Brut::FrontEnd::Components::Time#initialize}
201
+ def time_tag(timestamp:nil,date:nil, **component_options, &contents)
201
202
  args = component_options.merge(timestamp:,date:)
202
- component(Brut::FrontEnd::Components::Time.new(**args))
203
+ component(Brut::FrontEnd::Components::Time.new(**args,&contents))
203
204
  end
204
205
 
205
206
  # Render the {Brut::FrontEnd::Components::ConstraintViolations} component for the given form's input.
@@ -11,6 +11,9 @@ class Brut::FrontEnd::Components::Time < Brut::FrontEnd::Component
11
11
  # @param attribute_format [Symbol] the I18n format key fragment to use to locate the strftime format for formatting *the `datetime` attribute* of the HTML element that this component renders. Generally, you want to leave this as the default of `:iso_8601`, however if you need to change it, you can. This value is appeneded to `"time.formats."` to form the complete key. `skip_year_if_same` is not used for this value.
12
12
  # @param only_contains_class [Hash] exists because `class` is a reserved word
13
13
  # @option only_contains_class [String] :class the value to use for the `class` attribute.
14
+ # @yield No parameters given. This is expected to return markup to appear inside the `<form>` element. If provided, this component
15
+ # will still render the `datetime` attribute, but not the inside. This is useful if you have a customized date or time display that
16
+ # you would like to be accessible. If omitted, the tag's contents will be the formated date or timestamp.
14
17
  def initialize(
15
18
  timestamp: nil,
16
19
  date: nil,
@@ -18,7 +21,8 @@ class Brut::FrontEnd::Components::Time < Brut::FrontEnd::Component
18
21
  skip_year_if_same: true,
19
22
  skip_dow_if_not_this_week: true,
20
23
  attribute_format: :iso_8601,
21
- **only_contains_class
24
+ **only_contains_class,
25
+ &contents
22
26
  )
23
27
  require_exactly_one!(timestamp:,date:)
24
28
 
@@ -65,6 +69,7 @@ class Brut::FrontEnd::Components::Time < Brut::FrontEnd::Component
65
69
  @format = found_format.to_sym
66
70
  @attribute_format = attribute_format.to_sym
67
71
  @class_attribute = only_contains_class[:class] || ""
72
+ @contents = contents
68
73
  end
69
74
 
70
75
  def render(clock:)
@@ -77,7 +82,11 @@ class Brut::FrontEnd::Components::Time < Brut::FrontEnd::Component
77
82
  datetime_attribute = ::I18n.l(adjusted_value,format: @attribute_format)
78
83
 
79
84
  html_tag(:time, class: @class_attribute, datetime: datetime_attribute) do
80
- ::I18n.l(adjusted_value,format: @format)
85
+ if @contents
86
+ @contents.()
87
+ else
88
+ ::I18n.l(adjusted_value,format: @format)
89
+ end
81
90
  end
82
91
  end
83
92
 
data/lib/brut/version.rb CHANGED
@@ -1,4 +1,4 @@
1
1
  module Brut
2
2
  # @!visibility private
3
- VERSION = "0.0.4"
3
+ VERSION = "0.0.5"
4
4
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: brut
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Bryant Copeland
8
8
  bindir: exe
9
9
  cert_chain: []
10
- date: 2025-02-20 00:00:00.000000000 Z
10
+ date: 2025-02-24 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: irb