File tree Expand file tree Collapse file tree 2 files changed +20
-10
lines changed Expand file tree Collapse file tree 2 files changed +20
-10
lines changed Original file line number Diff line number Diff line change 1
1
=== master
2
2
3
+ * Add Labeler::Explicit#id_for_input private method to allow subclasses to easily get the id (jeremyevans)
4
+
3
5
* Support Sequel::Model#forme_required_abbr_title to control the content of the title attribute for abbr tags (jeremyevans)
4
6
5
7
* Add Serializer#self_closing_tag? private method for easier overriding in subclasses (jeremyevans)
Original file line number Diff line number Diff line change @@ -50,16 +50,7 @@ class Labeler::Explicit
50
50
# :label_for option is used, the label created will not be
51
51
# associated with an input.
52
52
def call ( tag , input )
53
- unless id = input . opts [ :id ]
54
- if key = input . opts [ :key ]
55
- namespaces = input . form_opts [ :namespace ]
56
- id = "#{ namespaces . join ( '_' ) } #{ '_' unless namespaces . empty? } #{ key } "
57
- if key_id = input . opts [ :key_id ]
58
- id += "_#{ key_id . to_s } "
59
- end
60
- end
61
- end
62
-
53
+ id = id_for_input ( input )
63
54
label_attr = input . opts [ :label_attr ]
64
55
label_attr = label_attr ? label_attr . dup : { }
65
56
label_attr [ :for ] ||= input . opts . fetch ( :label_for , id )
@@ -76,6 +67,23 @@ def call(tag, input)
76
67
77
68
t
78
69
end
70
+
71
+ private
72
+
73
+ # Determine the appropriate id for the input, to use in the for attribute
74
+ def id_for_input ( input )
75
+ unless id = input . opts [ :id ]
76
+ if key = input . opts [ :key ]
77
+ namespaces = input . form_opts [ :namespace ]
78
+ id = "#{ namespaces . join ( '_' ) } #{ '_' unless namespaces . empty? } #{ key } "
79
+ if key_id = input . opts [ :key_id ]
80
+ id += "_#{ key_id . to_s } "
81
+ end
82
+ end
83
+ end
84
+
85
+ id
86
+ end
79
87
end
80
88
81
89
class Labeler ::Span
You can’t perform that action at this time.
0 commit comments