roda-tags 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +9 -0
- data/.travis.yml +4 -0
- data/CODE_OF_CONDUCT.md +24 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/README.md +1083 -0
- data/Rakefile +21 -0
- data/lib/core_ext/blank.rb +158 -0
- data/lib/core_ext/hash.rb +47 -0
- data/lib/core_ext/object.rb +31 -0
- data/lib/core_ext/string.rb +330 -0
- data/lib/roda/plugins/tag_helpers.rb +919 -0
- data/lib/roda/plugins/tags.rb +452 -0
- data/lib/roda/tags.rb +3 -0
- data/lib/roda/tags/version.rb +8 -0
- data/roda-tags.gemspec +49 -0
- metadata +237 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: ebccb23d95fa9ec3d66cc17bb37eff691b99636d
|
4
|
+
data.tar.gz: d818548ad0699a72f7683d6d536f3c77f21aeb4b
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: e4c391ba728a0dc9848d143591ccb9f64bccb735176992519ee689b1922f8d45bfe9c7a49591e11b511603ff924a6a7806931fd1be947eaf77c622d6b5ef8e66
|
7
|
+
data.tar.gz: b1b41384c842744c45483715e3fda84455dda1c17db71e5757ae92802d708c404007ffe973efb71ad200391c748fcb3b58c50773987701a0cded46dc9354e89f
|
data/.gitignore
ADDED
data/.travis.yml
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
# Contributor Code of Conduct
|
2
|
+
|
3
|
+
As contributors and maintainers of this project, we pledge to respect all people who contribute
|
4
|
+
through reporting issues, posting feature requests, updating documentation, submitting pull
|
5
|
+
requests or patches, and other activities.
|
6
|
+
|
7
|
+
We are committed to making participation in this project a harassment-free experience for everyone,
|
8
|
+
regardless of level of experience, gender, gender identity and expression, sexual orientation,
|
9
|
+
disability, personal appearance, body size, race, ethnicity, age, or religion.
|
10
|
+
|
11
|
+
Examples of unacceptable behavior by participants include the use of sexual language or imagery,
|
12
|
+
derogatory comments or personal attacks, trolling, public or private harassment, insults, or other
|
13
|
+
unprofessional conduct.
|
14
|
+
|
15
|
+
Project maintainers have the right and responsibility to remove, edit, or reject comments, commits,
|
16
|
+
code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct.
|
17
|
+
Project maintainers who do not follow the Code of Conduct may be removed from the project team.
|
18
|
+
|
19
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by opening an
|
20
|
+
issue or contacting one or more of the project maintainers.
|
21
|
+
|
22
|
+
This Code of Conduct is adapted from the [Contributor Covenant](http://contributor-covenant.org),
|
23
|
+
version 1.0.0, available at [http://contributor-covenant.org/version/1/0/0/](http://contributor-covenant.org/version/1/0/0/)
|
24
|
+
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2015 Kematzy
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,1083 @@
|
|
1
|
+
# Roda::Tags
|
2
|
+
|
3
|
+
A [Roda](http://roda.jeremyevans.net/) plugin providing easy creation of flexible HTML tags within Roda apps or Roda plugins.
|
4
|
+
|
5
|
+
Extensively tested and with 100% code test coverage.
|
6
|
+
|
7
|
+
|
8
|
+
## Installation
|
9
|
+
|
10
|
+
To use this gem, just do
|
11
|
+
|
12
|
+
```bash
|
13
|
+
$ (sudo) gem install roda-tags
|
14
|
+
```
|
15
|
+
|
16
|
+
or preferably add this to your Gemfile for Bundler
|
17
|
+
|
18
|
+
|
19
|
+
```ruby
|
20
|
+
gem 'roda-tags'
|
21
|
+
```
|
22
|
+
|
23
|
+
<br>
|
24
|
+
|
25
|
+
## Getting Started
|
26
|
+
|
27
|
+
To use Roda::Tags just ensure the gem is included in the Gemfile and then...
|
28
|
+
|
29
|
+
...add the plugin to your app...
|
30
|
+
|
31
|
+
```bash
|
32
|
+
class MyApp < Roda
|
33
|
+
|
34
|
+
plugin :tags # see Configurations below for options
|
35
|
+
# or
|
36
|
+
plugin :tag_helpers # , options
|
37
|
+
|
38
|
+
# <snip...>
|
39
|
+
end
|
40
|
+
```
|
41
|
+
|
42
|
+
...or include the plugin in your own Roda plugin.
|
43
|
+
|
44
|
+
```ruby
|
45
|
+
class Roda
|
46
|
+
module RodaPlugins
|
47
|
+
module YourPlugin
|
48
|
+
|
49
|
+
def self.load_dependencies(app, opts={})
|
50
|
+
app.plugin :tags, opts
|
51
|
+
# or
|
52
|
+
app.plugin :tag_helpers, opts
|
53
|
+
end
|
54
|
+
|
55
|
+
# <snip...>
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
```
|
60
|
+
<br>
|
61
|
+
|
62
|
+
## Usage
|
63
|
+
|
64
|
+
|
65
|
+
|
66
|
+
<br>
|
67
|
+
|
68
|
+
## Key Methods / Functionality
|
69
|
+
|
70
|
+
|
71
|
+
<br>
|
72
|
+
|
73
|
+
|
74
|
+
Roda::Tags contains two plugins - [`:tags`, `:tag_helpers`] - that can be used independently or together.
|
75
|
+
|
76
|
+
**Note!** The `:tags` plugin is loaded by the `:tag_helpers` plugin.
|
77
|
+
|
78
|
+
<br>
|
79
|
+
|
80
|
+
## 1. `:tags` Plugin
|
81
|
+
|
82
|
+
|
83
|
+
This plugin have one **key public method** - `tag()`, which supports this **dynamic** syntax:
|
84
|
+
|
85
|
+
|
86
|
+
### -- `tag(*args, &block)`
|
87
|
+
|
88
|
+
|
89
|
+
```ruby
|
90
|
+
tag(name)
|
91
|
+
tag(name, &block)
|
92
|
+
|
93
|
+
tag(name, content)
|
94
|
+
tag(name, content, attributes)
|
95
|
+
tag(name, content, attributes, &block)
|
96
|
+
|
97
|
+
tag(name, attributes)
|
98
|
+
tag(name, attributes, &block)
|
99
|
+
```
|
100
|
+
|
101
|
+
This makes the method very flexible as can be seen below.
|
102
|
+
|
103
|
+
|
104
|
+
#### Self closing tags
|
105
|
+
|
106
|
+
```ruby
|
107
|
+
tag(:br) #=> <br> or <br/> if XHTML
|
108
|
+
|
109
|
+
tag(:hr, class: :divider) #=> <hr class="divider">
|
110
|
+
```
|
111
|
+
|
112
|
+
#### Multi line tags
|
113
|
+
|
114
|
+
```ruby
|
115
|
+
tag(:div) #=> <div></div>
|
116
|
+
|
117
|
+
tag(:div, 'content')
|
118
|
+
# <div>
|
119
|
+
# content
|
120
|
+
# </div>
|
121
|
+
|
122
|
+
tag(:div, 'content', id: 'comment')
|
123
|
+
# <div id="comment">
|
124
|
+
# content
|
125
|
+
# </div>
|
126
|
+
|
127
|
+
|
128
|
+
# NB! no content
|
129
|
+
tag(:div, id: :comment)
|
130
|
+
#=> <div id="comment"></div>
|
131
|
+
|
132
|
+
```
|
133
|
+
|
134
|
+
#### Single line tags
|
135
|
+
|
136
|
+
```ruby
|
137
|
+
tag(:h1,'Header') #=> <h1>Header</h1>
|
138
|
+
|
139
|
+
tag(:abbr, 'UN', title: "United Nations") #=> <abbr title="United Nations">UN</abbr>
|
140
|
+
```
|
141
|
+
|
142
|
+
#### Working with blocks
|
143
|
+
|
144
|
+
```ruby
|
145
|
+
tag(:div) do
|
146
|
+
tag(:p, 'Hello World')
|
147
|
+
end
|
148
|
+
# <div>
|
149
|
+
# <p>Hello World</p>
|
150
|
+
# </div>
|
151
|
+
|
152
|
+
|
153
|
+
<% tag(:ul) do %>
|
154
|
+
<li>item 1</li>
|
155
|
+
<%= tag(:li, 'item 2') %>
|
156
|
+
<li>item 3</li>
|
157
|
+
<% end %>
|
158
|
+
# <ul>
|
159
|
+
# <li>item 1</li>
|
160
|
+
# <li>item 2</li>
|
161
|
+
# <li>item 3</li>
|
162
|
+
# </ul>
|
163
|
+
|
164
|
+
|
165
|
+
# NOTE: ignores tag contents when given a block
|
166
|
+
<% tag(:div, 'ignored tag-content') do %>
|
167
|
+
<%= tag(:label, 'Comments:', for: :comments) %>
|
168
|
+
<%= tag(:textarea,'textarea contents', id: :comments) %>
|
169
|
+
<% end %>
|
170
|
+
# <div>
|
171
|
+
# <label for="comments">Comments:</label>
|
172
|
+
# <textarea id="comments">
|
173
|
+
# textarea contents
|
174
|
+
# </textarea>
|
175
|
+
# </div>
|
176
|
+
```
|
177
|
+
|
178
|
+
|
179
|
+
#### Boolean attributes
|
180
|
+
|
181
|
+
```ruby
|
182
|
+
tag(:input, type: :checkbox, checked: true)
|
183
|
+
#=> <input checked="checked" type="checkbox">
|
184
|
+
|
185
|
+
tag(:option, 'Roda', value: "1" selected: true)
|
186
|
+
#=> <option selected="selected" value="1">Roda</option>
|
187
|
+
|
188
|
+
tag(:option, 'PHP', value: "0" selected: false)
|
189
|
+
#=> <option value="0">PHP</option>
|
190
|
+
```
|
191
|
+
|
192
|
+
<br>
|
193
|
+
|
194
|
+
The plugin also have a few other public helper methods:
|
195
|
+
|
196
|
+
|
197
|
+
### -- `merge_attr_classes(attr, *classes)`
|
198
|
+
|
199
|
+
Updates `attr[:class]` in the hash with the given `classes` and returns `attr`.
|
200
|
+
|
201
|
+
```ruby
|
202
|
+
attr = { class: 'alert', id: :idval }
|
203
|
+
|
204
|
+
merge_attr_classes(attr, 'alert-info')
|
205
|
+
#=> { class: 'alert alert-info', id: :idval }
|
206
|
+
|
207
|
+
merge_attr_classes(attr, [:alert, 'alert-info'])
|
208
|
+
#=> { class: 'alert alert-info', id: :idval }
|
209
|
+
```
|
210
|
+
|
211
|
+
<br>
|
212
|
+
|
213
|
+
|
214
|
+
|
215
|
+
### -- `merge_classes(*classes)`
|
216
|
+
|
217
|
+
Returns an alphabetised string from all given class values.
|
218
|
+
|
219
|
+
The method correctly handles a combination of `arrays`, `strings` & `symbols` being passed in.
|
220
|
+
|
221
|
+
```ruby
|
222
|
+
attr = { class: 'alert', id: :idval }
|
223
|
+
|
224
|
+
merge_classes(attr[:class], ['alert', 'alert-info']) #=> 'alert alert-info'
|
225
|
+
|
226
|
+
merge_classes(attr[:class], :text) #=> 'alert text'
|
227
|
+
|
228
|
+
merge_classes(attr[:class], [:text, :'alert-info']) #=> 'alert alert-info text'
|
229
|
+
```
|
230
|
+
|
231
|
+
<br>
|
232
|
+
|
233
|
+
### Included Helper methods
|
234
|
+
|
235
|
+
The `:tags` plugin also includes a few useful public helper methods for use within other methods or gems.
|
236
|
+
|
237
|
+
|
238
|
+
### -- `capture(block='')`
|
239
|
+
|
240
|
+
Captures and returns a captured `ERB` block and restores the buffer afterwards.
|
241
|
+
|
242
|
+
<br>
|
243
|
+
|
244
|
+
|
245
|
+
### -- `capture_html(*args, &block)`
|
246
|
+
|
247
|
+
Captures the HTML from a block of template code for `ERB` or `HAML`.
|
248
|
+
|
249
|
+
```ruby
|
250
|
+
def some_method(*args, &block)
|
251
|
+
# <snip...>
|
252
|
+
res = capture_html(&block)
|
253
|
+
# <snip...>
|
254
|
+
end
|
255
|
+
```
|
256
|
+
|
257
|
+
<br>
|
258
|
+
|
259
|
+
|
260
|
+
### -- `concat_content(text="")`
|
261
|
+
|
262
|
+
Outputs the given content to the buffer directly.
|
263
|
+
|
264
|
+
```ruby
|
265
|
+
concat_content("This will be concatenated to the buffer")
|
266
|
+
```
|
267
|
+
|
268
|
+
<br>
|
269
|
+
|
270
|
+
|
271
|
+
### -- `block_is_template?(block)`
|
272
|
+
|
273
|
+
Returns `true` if the block is from an `ERB` or `HAML` template; `false` otherwise. Used to determine if contents should be returned or concatenated to output.
|
274
|
+
|
275
|
+
<br>
|
276
|
+
|
277
|
+
---
|
278
|
+
|
279
|
+
<br>
|
280
|
+
|
281
|
+
|
282
|
+
## 2. `:tag_helpers` Plugin
|
283
|
+
|
284
|
+
<br>
|
285
|
+
|
286
|
+
#### -- `form_tag(action, attrs={}, &block)`
|
287
|
+
|
288
|
+
Constructs a `<form>` without an object based on options passed.
|
289
|
+
|
290
|
+
```ruby
|
291
|
+
form_tag('/register') do
|
292
|
+
...
|
293
|
+
end
|
294
|
+
# <form action="/register" id="register-form" method="post">
|
295
|
+
# ...
|
296
|
+
# </form>
|
297
|
+
```
|
298
|
+
Automatically adds a hidden *faux method* when `:method` is NOT either `POST` or `GET`.
|
299
|
+
|
300
|
+
```ruby
|
301
|
+
form_tag('/user/1/profile', method: :put, id: 'profile-form')
|
302
|
+
...
|
303
|
+
end
|
304
|
+
# <form action="/user/1/profile" id="profile-form" method="post" >
|
305
|
+
# <input name="_method" type="hidden" value="put"/>
|
306
|
+
# ...
|
307
|
+
# </form>
|
308
|
+
```
|
309
|
+
|
310
|
+
Add multipart support via:
|
311
|
+
|
312
|
+
```ruby
|
313
|
+
form_tag('/upload', multipart: true)
|
314
|
+
# or
|
315
|
+
form_tag('/upload', multipart: 'multipart/form-data')
|
316
|
+
# or
|
317
|
+
form_tag('/upload', enctype: 'multipart/form-data')
|
318
|
+
# <form enctype="multipart/form-data" method="post" action="/upload">
|
319
|
+
# ...
|
320
|
+
# </form>
|
321
|
+
```
|
322
|
+
|
323
|
+
<br>
|
324
|
+
---
|
325
|
+
|
326
|
+
|
327
|
+
### -- `label_tag(field, attrs={}, &block)`
|
328
|
+
|
329
|
+
Constructs a `<label>` tag from the given options.
|
330
|
+
|
331
|
+
|
332
|
+
By default appends `':'` to the label name, based upon the plugin config `:tags_label_append ` value.
|
333
|
+
|
334
|
+
```ruby
|
335
|
+
label_tag(:name)
|
336
|
+
#=> <label for="name">Name:</label>
|
337
|
+
|
338
|
+
label_tag(:name, label: 'Custom label', class: 'sr-only')
|
339
|
+
#=> <label class="sr-only" for="name">Custom label:</label>
|
340
|
+
|
341
|
+
# uses a humanized version of the label name if { label: nil }
|
342
|
+
label_tag(:name, label: nil)
|
343
|
+
#=> <label for="name">Name:</label>
|
344
|
+
|
345
|
+
# removes the label text when { label: :false }
|
346
|
+
label_tag(:name, label: false)
|
347
|
+
#=> <label for="name"></label>
|
348
|
+
```
|
349
|
+
|
350
|
+
By default adds `'<span>*</span>'` to the label name when `{ required: true }` is passed. Based upon the plugin config `:tags_label_required_str ` value.
|
351
|
+
|
352
|
+
|
353
|
+
```ruby
|
354
|
+
label_tag(:name, required: true)
|
355
|
+
#=> <label for="name">Name: <span>*</span></label>
|
356
|
+
```
|
357
|
+
|
358
|
+
Label tags also supports passing blocks.
|
359
|
+
|
360
|
+
```ruby
|
361
|
+
<% label_tag(:remember_me) do %>
|
362
|
+
<%= checkbox_tag :remember_me %>
|
363
|
+
<% end %>
|
364
|
+
# <label for="remember_me">Remember Me:
|
365
|
+
# <input class="checkbox" id="remember_me" name="remember_me" type="checkbox" value="1">
|
366
|
+
# </label>
|
367
|
+
```
|
368
|
+
|
369
|
+
|
370
|
+
<br>
|
371
|
+
---
|
372
|
+
|
373
|
+
### -- `hidden_field_tag(name, attrs={})`
|
374
|
+
|
375
|
+
|
376
|
+
Constructs a hidden input field from the given options. Only `[:value, :id, :name]` attributes are allowed.
|
377
|
+
|
378
|
+
|
379
|
+
```ruby
|
380
|
+
hidden_field_tag(:snippet_name)
|
381
|
+
#=> <input id="snippet_name" name="snippet_name" type="hidden">
|
382
|
+
|
383
|
+
hidden_field_tag(:csrf, value: 'tokenval')
|
384
|
+
#=> <input id="csrf" name="csrf" type="hidden" value="tokenval">
|
385
|
+
|
386
|
+
hidden_field_tag(:snippet_id, id: 'some-id')
|
387
|
+
#=> <input id="some-id" name="snippet_id" type="hidden">
|
388
|
+
|
389
|
+
# removing the `:id` attribute completely.
|
390
|
+
hidden_field_tag(:snippet_name, id: false)
|
391
|
+
#=> <input name="snippet_name" type="hidden">
|
392
|
+
```
|
393
|
+
|
394
|
+
<br>
|
395
|
+
---
|
396
|
+
|
397
|
+
### -- `text_field_tag(name, attrs={}) `
|
398
|
+
- *also aliased as* `textfield_tag()`
|
399
|
+
|
400
|
+
Creates a standard `<input type="text"...>` field from the given options.
|
401
|
+
|
402
|
+
```ruby
|
403
|
+
text_field_tag(:snippet_name)
|
404
|
+
#=> <input class="text" id="snippet_name" name="snippet_name" type="text">
|
405
|
+
|
406
|
+
text_field_tag(:name, value: 'some-value')
|
407
|
+
#=> <input class="text" id="name" name="name" type="text" value="some-value">
|
408
|
+
|
409
|
+
text_field_tag(:name, id: 'some-id')
|
410
|
+
#=> <input class="text" id="some-id" name="name" type="text">
|
411
|
+
|
412
|
+
# removing the `:id` attribute completely. NB! bad practice.
|
413
|
+
text_field_tag(:name, id: false)
|
414
|
+
#=> <input class="text" name="name" type="text">
|
415
|
+
|
416
|
+
# append a CSS class to the existing class.
|
417
|
+
text_field_tag(:name, class: :big)
|
418
|
+
#=> <input class="big text" id="name" name="name" type="text">
|
419
|
+
|
420
|
+
# adds a `:title` attribute when passed `:ui_hint`
|
421
|
+
text_field_tag(:name, ui_hint: 'a user hint')
|
422
|
+
#=> <input class="text" id="name" name="name" title="a user hint" type="text">
|
423
|
+
|
424
|
+
# supports `:maxlength` & `:size` attributes
|
425
|
+
text_field_tag(:ip, maxlength: 15, size: 20)
|
426
|
+
#=> <input class="text" id="ip" maxlength="15" name="ip" size="20" type="text">
|
427
|
+
|
428
|
+
# `:disabled` attribute
|
429
|
+
text_field_tag(:name, disabled: true)
|
430
|
+
#=> <input class="text" disabled="disabled" id="name" name="name" type="text">
|
431
|
+
|
432
|
+
# `:readonly` attribute
|
433
|
+
text_field_tag(:name, readonly: true)
|
434
|
+
#=> <input class="text" id="name" name="name" readonly="readonly" type="text">
|
435
|
+
```
|
436
|
+
|
437
|
+
<br>
|
438
|
+
---
|
439
|
+
|
440
|
+
### -- `password_field_tag(name, attrs={})`
|
441
|
+
- *also aliased as* `passwordfield_tag()`
|
442
|
+
|
443
|
+
Constructs a `<input type="password"...>` field from the given options.
|
444
|
+
|
445
|
+
```ruby
|
446
|
+
password_field_tag(:snippet_name)
|
447
|
+
#=> <input class="text" id="snippet_name" name="snippet_name" type="password">
|
448
|
+
|
449
|
+
password_field_tag(:snippet_name, value: 'some-value')
|
450
|
+
#=> <input class="text" id="snippet_name" name="snippet_name" type="password" value="some-value">
|
451
|
+
|
452
|
+
password_field_tag(:snippet_name, id: 'some-id')
|
453
|
+
#=> <input class="text" id="some-id" name="snippet_name" type="password">
|
454
|
+
|
455
|
+
password_field_tag(:snippet_name, id: false)
|
456
|
+
#=> <input class="text" name="snippet_name" type="password">
|
457
|
+
|
458
|
+
# append a CSS class to the existing class. Default class: `.text`.
|
459
|
+
password_field_tag(:snippet_name, class: :big )
|
460
|
+
#=> <input class="big text" id="snippet_name" name="snippet_name" type="password">
|
461
|
+
|
462
|
+
# adds a `:title` attribute when passed `:ui_hint`
|
463
|
+
password_field_tag(:name, ui_hint: 'a user hint')
|
464
|
+
#=> <input class="text" id="name" name="name" title="a user hint" type="password">
|
465
|
+
|
466
|
+
# supports `:maxlength` & `:size` attributes
|
467
|
+
password_field_tag(:ip_address, maxlength: 15, size: 20)
|
468
|
+
#=> <input class="text" id="ip_address" maxlength="15" name="ip_address" size="20" type="password">
|
469
|
+
|
470
|
+
# `disabled` attribute
|
471
|
+
password_field_tag(:name, disabled: true)
|
472
|
+
password_field_tag(:name, disabled: :disabled)
|
473
|
+
#=> <input class="text" id="name" disabled="disabled" name="name" type="password">
|
474
|
+
```
|
475
|
+
|
476
|
+
<br>
|
477
|
+
---
|
478
|
+
|
479
|
+
|
480
|
+
### -- `file_field_tag(name, attrs={})`
|
481
|
+
- *also aliased as* `filefield_tag()`
|
482
|
+
|
483
|
+
Creates an `<input type="file"...>` field from given options.
|
484
|
+
|
485
|
+
**NOTE!** If you are using file uploads then you will also need to set the multipart option for the form tag, like this:
|
486
|
+
|
487
|
+
```ruby
|
488
|
+
<% form_tag('/upload', multipart: true) do %>
|
489
|
+
<%= label_tag(:file, label: "File to Upload") %>
|
490
|
+
<%= file_field_tag "file" %>
|
491
|
+
<%= submit_tag %>
|
492
|
+
<% end %>
|
493
|
+
```
|
494
|
+
|
495
|
+
The specified URL will then be passed a File object containing the selected file, or if the field was left blank, a StringIO object.
|
496
|
+
|
497
|
+
|
498
|
+
```ruby
|
499
|
+
file_field_tag('attachment')
|
500
|
+
#=> <input class="file" id="attachment" name="attachment" type="file">
|
501
|
+
|
502
|
+
# ignores invalid :value attribute.
|
503
|
+
file_field_tag(:photo, value: 'some-value')
|
504
|
+
#=> <input class="file" id="photo" name="photo" type="file">
|
505
|
+
|
506
|
+
file_field_tag(:photo, id: 'some-id')
|
507
|
+
#=> <input class="file" id="some-id" name="photo" type="file">
|
508
|
+
|
509
|
+
# removing the `:id` attribute completely. NB! bad practice.
|
510
|
+
file_field_tag(:photo, id: false)
|
511
|
+
#=> <input class="file" name="photo" type="file">
|
512
|
+
|
513
|
+
# append a CSS class to the existing class. Default class: `.file`.
|
514
|
+
file_field_tag(:photo, class: :big )
|
515
|
+
#=> <input class="big file" id="photo" name="photo" type="file">
|
516
|
+
|
517
|
+
# adds a `:title` attribute when passed `:ui_hint`.
|
518
|
+
file_field_tag(:photo, ui_hint: 'a user hint')
|
519
|
+
#=> <input class="file" id="photo" name="photo" title="a user hint" type="file">
|
520
|
+
|
521
|
+
# `:disabled` attribute
|
522
|
+
file_field_tag(:photo, disabled: true)
|
523
|
+
#=> <input class="file" disabled="disabled" id="photo" name="photo" type="file">
|
524
|
+
|
525
|
+
# `:accept` attribute is subject to actual browser support.
|
526
|
+
file_field_tag(:photo, accept: 'image/png,image/jpeg' )
|
527
|
+
#=> <input accept="image/png,image/jpeg" class="file" id="photo" name="photo" type="file">
|
528
|
+
```
|
529
|
+
|
530
|
+
<br>
|
531
|
+
---
|
532
|
+
|
533
|
+
|
534
|
+
### -- `textarea_tag(name, attrs={})`
|
535
|
+
- *also aliased as* `text_area_tag()`
|
536
|
+
|
537
|
+
Constructs a textarea input from the given options.
|
538
|
+
|
539
|
+
**TODO:** enable :escape functionality. How??
|
540
|
+
|
541
|
+
* `:escape` - By default, the contents of the text input are HTML escaped. If you need unescaped contents, set this to false.
|
542
|
+
|
543
|
+
|
544
|
+
```ruby
|
545
|
+
textarea_tag('post')
|
546
|
+
#=> <textarea id="post" name="post">\n</textarea>
|
547
|
+
|
548
|
+
# add a value
|
549
|
+
textarea_tag(:bio, value: @actor.bio)
|
550
|
+
#=> <textarea id="bio" name="bio">This is my biography.\n</textarea>
|
551
|
+
|
552
|
+
# set a different :id
|
553
|
+
textarea_tag(:body, id: 'some-id')
|
554
|
+
#=> <textarea id="some-id" name="post">...</textarea>
|
555
|
+
|
556
|
+
# adds a CSS class. NB! :textarea have no default class.
|
557
|
+
textarea_tag(:body, class: 'big')
|
558
|
+
#=> <textarea class="big" id="post" name="post">...</textarea>
|
559
|
+
|
560
|
+
# adds a `:title` attribute when passed `:ui_hint`
|
561
|
+
textarea_tag(:body, ui_hint: 'a user hint')
|
562
|
+
#=> <textarea id="post" name="post" title="a user hint">...</textarea>
|
563
|
+
|
564
|
+
# supports `:rows` & `:cols` attributes
|
565
|
+
textarea_tag('body', rows: 10, cols: 25)
|
566
|
+
#=> <textarea cols="25" id="body" name="body" rows="10">...</textarea>
|
567
|
+
|
568
|
+
# alternative `:size` shortcut to set `:rows` & `:cols`
|
569
|
+
textarea_tag('body', size: "25x10")
|
570
|
+
#=> <textarea cols="25" id="body" name="body" rows="10">...</textarea>
|
571
|
+
|
572
|
+
# `:disabled` attribute
|
573
|
+
textarea_tag(:description, disabled: true)
|
574
|
+
#=> <textarea disabled="disabled" id="description" name="description">...</textarea>
|
575
|
+
|
576
|
+
# `:readonly` attribute
|
577
|
+
textarea_tag(:description, readonly: true)
|
578
|
+
#=> <textarea id="description" name="description" readonly="readonly">...</textarea>
|
579
|
+
```
|
580
|
+
|
581
|
+
<br>
|
582
|
+
---
|
583
|
+
|
584
|
+
### -- `field_set_tag(*args, &block)`
|
585
|
+
- *also aliased as* `fieldset_tag()`
|
586
|
+
|
587
|
+
Creates a `<fieldset..>` tag for grouping HTML form elements.
|
588
|
+
|
589
|
+
```ruby
|
590
|
+
field_set_tag(:actor)
|
591
|
+
# <fieldset id="fieldset-actor">
|
592
|
+
# <legend>Actor</legend>
|
593
|
+
# ...
|
594
|
+
# </fieldset>
|
595
|
+
|
596
|
+
# sets the `<legend>` and `:id` attribute when given a single argument.
|
597
|
+
field_set_tag('User Details') do
|
598
|
+
...
|
599
|
+
end
|
600
|
+
# <fieldset id="fieldset-user-details">
|
601
|
+
# <legend>User Details</legend>
|
602
|
+
# ...
|
603
|
+
# </fieldset>
|
604
|
+
|
605
|
+
# supports `:legend` attribute
|
606
|
+
field_set_tag(:actor, legend: 'Details')
|
607
|
+
# <fieldset id="fieldset-actor">
|
608
|
+
# <legend>Details</legend>
|
609
|
+
# <snip...>
|
610
|
+
|
611
|
+
# remove `<legend>` tag by `{ legend: false }`
|
612
|
+
field_set_tag(:actor, legend: 'Details')
|
613
|
+
# <fieldset id="fieldset-actor">
|
614
|
+
# <legend>Details</legend>
|
615
|
+
# <snip...>
|
616
|
+
|
617
|
+
# append a CSS class. NB! fieldset has no other class by default.
|
618
|
+
field_set_tag(:actor, class: 'legend-class')
|
619
|
+
# <fieldset class="legend-class" id="fieldset-actor">
|
620
|
+
# <snip...>
|
621
|
+
|
622
|
+
# default to 'fieldset' when passed `nil` as the first arg
|
623
|
+
field_set_tag(nil, class: 'format')
|
624
|
+
# <fieldset class="format" id="fieldset">
|
625
|
+
# <snip...>
|
626
|
+
|
627
|
+
# removing the `:id` attribute completely
|
628
|
+
field_set_tag('Users', id: false)
|
629
|
+
# <fieldset>
|
630
|
+
# <legend>Users</legend>
|
631
|
+
# <snip...>
|
632
|
+
```
|
633
|
+
|
634
|
+
<br>
|
635
|
+
---
|
636
|
+
|
637
|
+
### -- `legend_tag(contents, attrs={})`
|
638
|
+
|
639
|
+
Return a legend with _contents_ from the given options.
|
640
|
+
|
641
|
+
|
642
|
+
```ruby
|
643
|
+
legend_tag('User Details')
|
644
|
+
#=> <legend>User Details</legend>
|
645
|
+
|
646
|
+
# adding an :id attribute.
|
647
|
+
legend_tag('User', id: 'some-id')
|
648
|
+
#=> <legend id="some-id">User</legend>
|
649
|
+
|
650
|
+
# adds a CSS class. NB! legend tags have no default class
|
651
|
+
legend_tag('User', class: 'some-class')
|
652
|
+
#=> <legend class="some-class">User</legend>
|
653
|
+
```
|
654
|
+
|
655
|
+
<br>
|
656
|
+
---
|
657
|
+
|
658
|
+
|
659
|
+
### -- `check_box_tag(name, attrs={})`
|
660
|
+
- also aliased as `checkbox_tag()`
|
661
|
+
|
662
|
+
Creates an `<input type="checkbox"...>` tag from the given options.
|
663
|
+
|
664
|
+
|
665
|
+
```ruby
|
666
|
+
check_box_tag(:accept) || checkbox_tag(:accept)
|
667
|
+
#=> <input class="checkbox" id="accept" name="accept" type="checkbox" value="1">
|
668
|
+
|
669
|
+
# providing a value
|
670
|
+
check_box_tag(:rock, value: 'rock music')
|
671
|
+
#=> <input class="checkbox" id="rock" name="rock" type="checkbox" value="rock music">
|
672
|
+
|
673
|
+
# setting a different :id
|
674
|
+
check_box_tag(:rock, :id => 'some-id')
|
675
|
+
#=> <input class="checkbox" id="some-id" name="rock" type="checkbox" value="1">
|
676
|
+
|
677
|
+
# append a CSS class. NB! default class: '.checkbox'
|
678
|
+
check_box_tag(:rock, class: 'small')
|
679
|
+
#=> <input class="small checkbox" id="rock" name="rock" type="checkbox" value="1">
|
680
|
+
|
681
|
+
# adds a `:title` attribute when passed `:ui_hint`
|
682
|
+
check_box_tag(:rock, ui_hint: 'a user hint')
|
683
|
+
#=> <input class="checkbox" id="rock" name="rock" title="a user hint" type="checkbox" value="1">
|
684
|
+
|
685
|
+
# `checked` attribute
|
686
|
+
check_box_tag(:rock, checked: true)
|
687
|
+
#=> <input checked="checked" class="checkbox" id="rock" name="rock" type="checkbox" value="1">
|
688
|
+
|
689
|
+
# `disabled` attribute
|
690
|
+
check_box_tag(:rock, disabled: true)
|
691
|
+
#=> <input class="checkbox" disabled="disabled" id="rock" name="rock" type="checkbox" value="1">
|
692
|
+
```
|
693
|
+
|
694
|
+
<br>
|
695
|
+
---
|
696
|
+
|
697
|
+
### -- `radio_button_tag(name, attrs={})`
|
698
|
+
- *also aliased as* `radiobutton_tag()`
|
699
|
+
|
700
|
+
Creates a `<input type="radio"...>` tag from the given options.
|
701
|
+
|
702
|
+
**NOTE!** use groups of radio buttons named the same to allow users to select from a group of options.
|
703
|
+
|
704
|
+
|
705
|
+
```ruby
|
706
|
+
radio_button_tag(:accept) || radiobutton_tag(:accept)
|
707
|
+
#=> <input class="radio" id="accept_1" name="accept" type="radio" value="1">
|
708
|
+
|
709
|
+
radio_button_tag(:rock, value:'rock music')
|
710
|
+
#=> <input class="radio" id="rock_rock-music" name="rock" type="radio" value="rock music">
|
711
|
+
|
712
|
+
# setting a different :id.
|
713
|
+
radio_button_tag(:rock, id: 'some-id')
|
714
|
+
#=> <input class="radio" id="some-id_1" name="rock" type="radio" value="1">
|
715
|
+
|
716
|
+
# append a CSS class. NB! default class: '.radio'
|
717
|
+
radio_button_tag(:rock, class: 'big')
|
718
|
+
#=> <input class="big radio" id="rock_1" name="rock" type="radio" value="1">
|
719
|
+
|
720
|
+
# adds a `:title` attribute when passed `:ui_hint`
|
721
|
+
radio_button_tag(:rock, ui_hint: 'a user hint')
|
722
|
+
#=> <input class="radio" id="rock_1" value="1" name="rock" title="a user hint" type="radio">
|
723
|
+
|
724
|
+
# `checked` attribute
|
725
|
+
radio_button_tag(:yes, checked: true)
|
726
|
+
#=> <input checked="checked" class="radio" id="yes_1" name="yes" type="radio" value="1">
|
727
|
+
|
728
|
+
# `disabled` attribute
|
729
|
+
radio_button_tag(:yes, disabled: true)
|
730
|
+
#=> <input disabled="disabled" class="radio" id="yes_1" name="yes" type="radio" value="1">
|
731
|
+
```
|
732
|
+
|
733
|
+
<br>
|
734
|
+
---
|
735
|
+
|
736
|
+
|
737
|
+
### -- `submit_tag(value="Save Form", attrs={})`
|
738
|
+
- *also aliased as* **`submit_button()`**
|
739
|
+
|
740
|
+
Creates a submit button with the text value as the caption.
|
741
|
+
|
742
|
+
```ruby
|
743
|
+
submit_tag() || submit_button()
|
744
|
+
#=> <input name="submit" type="submit" value="Save Form">
|
745
|
+
|
746
|
+
submit_tag(nil)
|
747
|
+
#=> <input name="submit" type="submit" value="">
|
748
|
+
|
749
|
+
submit_tag('Custom Value')
|
750
|
+
#=> <input name="submit" type="submit" value="Custom Value">
|
751
|
+
|
752
|
+
# adds a CSS class. NB! input[:submit] has no other class by default.
|
753
|
+
submit_tag(class: 'some-class')
|
754
|
+
#=> <input class="some-class" name="submit" type="submit" value="Save Form">
|
755
|
+
|
756
|
+
# supports the :disabled attribute.
|
757
|
+
submit_tag('disabled: true)
|
758
|
+
#=> <input disabled="disabled" name="submit" type="submit" value="Save Form">
|
759
|
+
|
760
|
+
# adds a `:title` attribute when passed `:ui_hint`.
|
761
|
+
submit_tag(ui_hint: 'a user hint')
|
762
|
+
#=> <input name="submit" title="a user hint" type="submit" value="Save Form">
|
763
|
+
```
|
764
|
+
|
765
|
+
<br>
|
766
|
+
---
|
767
|
+
|
768
|
+
### -- `image_submit_tag(src, attrs={})`
|
769
|
+
|
770
|
+
Adds a `<input src=""...>` tag which displays an image.
|
771
|
+
|
772
|
+
|
773
|
+
```ruby
|
774
|
+
@img = '/img/btn.png'
|
775
|
+
|
776
|
+
image_submit_tag(@img)
|
777
|
+
#=> <input src="/img/btn.png" type="image">
|
778
|
+
|
779
|
+
image_submit_tag(@img, disabled: true)
|
780
|
+
#=> <input disabled="disabled" src="/img/btn.png" type="image">
|
781
|
+
|
782
|
+
image_submit_tag(@img, class 'search-button')
|
783
|
+
#=> <input class="search-button" src="/img/btn.png" type="image">
|
784
|
+
```
|
785
|
+
|
786
|
+
<br>
|
787
|
+
---
|
788
|
+
|
789
|
+
### -- `reset_tag(value='Reset Form', attrs={})`
|
790
|
+
- *also aliased as* **`reset_button()`**
|
791
|
+
|
792
|
+
Creates a reset button with the text value as the caption.
|
793
|
+
|
794
|
+
```ruby
|
795
|
+
reset_tag() || reset_button()
|
796
|
+
#=> <input name="reset" type="reset" value="Reset Form">
|
797
|
+
|
798
|
+
reset_tag(nil)
|
799
|
+
#=> <input name="reset" type="reset" value="">
|
800
|
+
|
801
|
+
reset_tag('Custom Value')
|
802
|
+
#=> <input name="reset" type="reset" value="Custom Value">
|
803
|
+
|
804
|
+
# adds a CSS class. NB! input[:reset] has no other class by default
|
805
|
+
reset_tag(class: 'some-class')
|
806
|
+
#=> <input class="some-class" name="reset" type="reset" value="Reset Form">
|
807
|
+
|
808
|
+
# supports the `:disabled` attribute
|
809
|
+
reset_tag(disabled: true)
|
810
|
+
#=> <input disabled="disabled" name="reset" type="reset" value="Reset Form">
|
811
|
+
|
812
|
+
# adds a `:title` attribute when passed `:ui_hint`
|
813
|
+
reset_tag(ui_hint: 'a user hint')
|
814
|
+
#=> <input name="reset" title="a user hint" type="submit" value="Reset Form">
|
815
|
+
```
|
816
|
+
|
817
|
+
<br>
|
818
|
+
---
|
819
|
+
|
820
|
+
### -- `select_tag(name, options, attrs={})`
|
821
|
+
|
822
|
+
Creates a `<select..>` tag (dropdown menu), including the various select options.
|
823
|
+
|
824
|
+
|
825
|
+
**Note!** the format for the options values must be `[value, key]`.
|
826
|
+
|
827
|
+
Passing options values as a `Hash`.
|
828
|
+
|
829
|
+
```ruby
|
830
|
+
select_tag(:letters, {a: 'A', b: 'B' })
|
831
|
+
# <select id="letters" name="letters">
|
832
|
+
# <option value="a">A</option>
|
833
|
+
# <option value="b">B</option>
|
834
|
+
# </select>
|
835
|
+
```
|
836
|
+
|
837
|
+
Passing options values as an `Array`.
|
838
|
+
|
839
|
+
```ruby
|
840
|
+
@letters = [[:a,'A'], [:b,'B']]
|
841
|
+
|
842
|
+
select_tag(:letters, @letters)
|
843
|
+
# <select id="letters" name="letters">
|
844
|
+
# <option value="a">A</option>
|
845
|
+
# <option value="b">B</option>
|
846
|
+
# </select>
|
847
|
+
```
|
848
|
+
|
849
|
+
Handling passed options:
|
850
|
+
|
851
|
+
```ruby
|
852
|
+
select_tag(:letters, @letters, disabled: true)
|
853
|
+
# <select id="letters" disabled="disabled" name="letters">
|
854
|
+
# <snip...>
|
855
|
+
|
856
|
+
select_tag(:letters, @letters, id: 'my-letters')
|
857
|
+
# <select id="my-letters" name="letters">
|
858
|
+
# <snip...>
|
859
|
+
|
860
|
+
select_tag(:letters, @letters, class: 'funky-select')
|
861
|
+
# <select class="funky-select" id="my-letters" name="letters">
|
862
|
+
# <snip...>
|
863
|
+
```
|
864
|
+
|
865
|
+
Handling the prompt value:
|
866
|
+
|
867
|
+
```ruby
|
868
|
+
select_tag(:letters, @letters, prompt: true)
|
869
|
+
# <select id="letters" name="letters">
|
870
|
+
# <option selected="selected" value="">- Select -</option>
|
871
|
+
# <snip...>
|
872
|
+
|
873
|
+
# setting a custom prompt
|
874
|
+
select_tag(:letters, @letters, prompt: 'Top Letters', selected: 'a')
|
875
|
+
# <select id="letters" name="letters">
|
876
|
+
# <option value="">Top Letters</option>
|
877
|
+
# <option selected="selected" value="a">A</option>
|
878
|
+
# <snip...>
|
879
|
+
```
|
880
|
+
|
881
|
+
Adding `:selected` option.
|
882
|
+
|
883
|
+
```ruby
|
884
|
+
select_tag(:letters, @letters, selected: :a)
|
885
|
+
# <select id="letters" name="letters">
|
886
|
+
# <option selected="selected" value="a">A</option>
|
887
|
+
# <snip...>
|
888
|
+
```
|
889
|
+
|
890
|
+
|
891
|
+
When passing multiple items to `:selected` option or setting the `{ multiple: true }` option, the select menu automatically becomes a multiple select box.
|
892
|
+
|
893
|
+
**NOTE!** the `name="letters[]"` attribute.
|
894
|
+
|
895
|
+
```ruby
|
896
|
+
select_tag(:letters, @letters, selected: [:a,'b'])
|
897
|
+
# <select id="letters" multiple="multiple" name="letters[]">
|
898
|
+
# <option selected="selected" value="a">A</option>
|
899
|
+
# <option selected="selected" value="b">B</option>
|
900
|
+
# </select>
|
901
|
+
|
902
|
+
select_tag(:letters, @letters, multiple: true)
|
903
|
+
# <select id="letters" name="letters[]" multiple="multiple">
|
904
|
+
# <snip...>
|
905
|
+
```
|
906
|
+
|
907
|
+
<br>
|
908
|
+
---
|
909
|
+
|
910
|
+
### -- `select_option(value, key, attrs={})`
|
911
|
+
|
912
|
+
Creates an `<option...>` tag for `<select...>` menus.
|
913
|
+
|
914
|
+
```ruby
|
915
|
+
select_option('a', 'Letter A')
|
916
|
+
#=> <option value="a">Letter A</option>
|
917
|
+
|
918
|
+
select_option('on', '') # , nil)
|
919
|
+
#=> <option value="on">On</option>
|
920
|
+
|
921
|
+
# handling selected options
|
922
|
+
select_option('a', 'Letter A', selected: true)
|
923
|
+
#=> <option selected="selected" value="a">Letter A</option>
|
924
|
+
|
925
|
+
select_option('a', 'Letter A', selected: false)
|
926
|
+
#=> <option value="a">Letter A</option>
|
927
|
+
```
|
928
|
+
|
929
|
+
<br>
|
930
|
+
---
|
931
|
+
|
932
|
+
### -- `faux_method(method='PUT')`
|
933
|
+
|
934
|
+
|
935
|
+
```ruby
|
936
|
+
faux_method() #=> <input name="_method" type="hidden" value="PUT">
|
937
|
+
|
938
|
+
# handling DELETE requests
|
939
|
+
faux_method(:delete) #=> <input name="_method" type="hidden" value="DELETE">
|
940
|
+
|
941
|
+
```
|
942
|
+
|
943
|
+
<br>
|
944
|
+
---
|
945
|
+
|
946
|
+
## Plugin Configurations
|
947
|
+
|
948
|
+
The default settings should help you get moving quickly, and are fairly common sense based.
|
949
|
+
|
950
|
+
However the `:tags` plugin supports these config options:
|
951
|
+
|
952
|
+
#### `:tag_output_format_is_xhtml`
|
953
|
+
|
954
|
+
Sets the HTML output format, toggling between `HTML 5` (`false`) and `XHTML` (`true`). Default is: `false`.
|
955
|
+
|
956
|
+
This option is retained for legacy support and in memory of the *"good old days"* ;-).
|
957
|
+
|
958
|
+
#### `:tag_add_newlines_after_tags`
|
959
|
+
|
960
|
+
Sets the formatting of the HTML output, whether it should be more compact in nature or slightly better formatted. Default is: `true`.
|
961
|
+
|
962
|
+
|
963
|
+
The `:tag_helpers` plugin supports these config options:
|
964
|
+
|
965
|
+
|
966
|
+
#### `:tags_label_required_str`
|
967
|
+
|
968
|
+
Sets the formatting of the string appended to required `<label...>` tags. Default is: `'<span>*</span>'`.
|
969
|
+
|
970
|
+
#### `:tags_label_append_str`
|
971
|
+
|
972
|
+
Sets the formatting of the string appended to `<label...>` tags. Default is: `':'`.
|
973
|
+
|
974
|
+
|
975
|
+
#### `:tags_forms_default_class`
|
976
|
+
|
977
|
+
Sets the default class value for form tags. Default is: `''` (empty).
|
978
|
+
|
979
|
+
This is a shortcut to automatically add something like [Bootstrap](https://getbootstrap.com/) support with `'form-control'`
|
980
|
+
|
981
|
+
|
982
|
+
**NOTE!**
|
983
|
+
|
984
|
+
Config options set in `:tag_helpers` are passed on to the `:tags` plugin.
|
985
|
+
|
986
|
+
```ruby
|
987
|
+
# <snip...>
|
988
|
+
# support legacy XHTML formatted output
|
989
|
+
plugin :tag_helpers, { tag_output_format_is_xhtml: true, ... }
|
990
|
+
# <snip...>
|
991
|
+
```
|
992
|
+
|
993
|
+
|
994
|
+
|
995
|
+
## RTFM
|
996
|
+
|
997
|
+
If the above is not clear enough, please check the specs for a better understanding.
|
998
|
+
|
999
|
+
<br>
|
1000
|
+
|
1001
|
+
## Errors / Bugs
|
1002
|
+
|
1003
|
+
If something is not behaving intuitively, it is a bug, and should be reported.
|
1004
|
+
Report it here: http://github.com/kematzy/roda-tags/issues
|
1005
|
+
|
1006
|
+
<br>
|
1007
|
+
|
1008
|
+
## TODOs
|
1009
|
+
|
1010
|
+
* Keep it up to date with any changes in `Roda` or `HTML`.
|
1011
|
+
|
1012
|
+
* Decide on if it's worth it to do validity checks on all attributes passed to tags
|
1013
|
+
ie: reject attributes based upon what is allowed for the tag.
|
1014
|
+
|
1015
|
+
```ruby
|
1016
|
+
tag(:base, href: 'url', target: '_self', id: 'is-ignored')
|
1017
|
+
#=> <base href="url", target="_self">
|
1018
|
+
```
|
1019
|
+
|
1020
|
+
* Decide on whether to add a number of convenience tags (methods), such as:
|
1021
|
+
|
1022
|
+
- ```meta(name, contents)```
|
1023
|
+
|
1024
|
+
- ```img(src, attrs={})```
|
1025
|
+
|
1026
|
+
|
1027
|
+
* Any other improvements we may think of.
|
1028
|
+
|
1029
|
+
|
1030
|
+
<br>
|
1031
|
+
|
1032
|
+
## Dependencies
|
1033
|
+
|
1034
|
+
This Gem depends upon the following:
|
1035
|
+
|
1036
|
+
### Runtime:
|
1037
|
+
|
1038
|
+
* roda (>= 2.5.0)
|
1039
|
+
* tilt
|
1040
|
+
* erubis
|
1041
|
+
|
1042
|
+
|
1043
|
+
### Development & Tests:
|
1044
|
+
|
1045
|
+
* bundler (~> 1.10)
|
1046
|
+
* rake (~> 10.0)
|
1047
|
+
* minitest
|
1048
|
+
* minitest-hooks
|
1049
|
+
* minitest-rg
|
1050
|
+
* rack-test
|
1051
|
+
* nokogiri => for the `assert_have_tag()` tests
|
1052
|
+
|
1053
|
+
* simplecov
|
1054
|
+
|
1055
|
+
|
1056
|
+
<br>
|
1057
|
+
|
1058
|
+
## Note on Patches/Pull Requests
|
1059
|
+
|
1060
|
+
* Fork the project.
|
1061
|
+
* Make your feature addition or bug fix.
|
1062
|
+
* Add tests for it. This is important so I don't break it in a future version unintentionally.
|
1063
|
+
* Commit, do not mess with Rakefile, version, or history.
|
1064
|
+
* (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
|
1065
|
+
* Send me a pull request. Bonus points for topic branches.
|
1066
|
+
|
1067
|
+
|
1068
|
+
<br>
|
1069
|
+
|
1070
|
+
## Copyright
|
1071
|
+
|
1072
|
+
Copyright (c) 2010-2015 Kematzy
|
1073
|
+
|
1074
|
+
Released under the MIT License. See LICENSE for further details.
|
1075
|
+
|
1076
|
+
<br>
|
1077
|
+
|
1078
|
+
## Code Inspirations:
|
1079
|
+
|
1080
|
+
* The ActiveSupport gem by DHH & Rails Core Team
|
1081
|
+
|
1082
|
+
|
1083
|
+
|