Skip to content

Commit dc581c0

Browse files
authored
Merge pull request rails#50171 from akhilgkrishnan/add-link-to-api-documentation
Add link to API documentation for ActionView helper method [skip ci]
2 parents 664eb0d + e61c4b3 commit dc581c0

File tree

1 file changed

+74
-2
lines changed

1 file changed

+74
-2
lines changed

guides/source/action_view_helpers.md

Lines changed: 74 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ audio_tag("sound")
4343
# => <audio src="/audios/sound"></audio>
4444
```
4545

46+
See the [API Documentation](https://api.rubyonrails.org/classes/ActionView/Helpers/AssetTagHelper.html#method-i-audio_tag) for more information.
47+
4648
#### auto_discovery_link_tag
4749

4850
Returns a link tag that browsers and feed readers can use to auto-detect an RSS, Atom, or JSON feed.
@@ -52,6 +54,8 @@ auto_discovery_link_tag(:rss, "http://www.example.com/feed.rss", { title: "RSS F
5254
# => <link rel="alternate" type="application/rss+xml" title="RSS Feed" href="http://www.example.com/feed.rss" />
5355
```
5456

57+
See the [API Documentation](https://api.rubyonrails.org/classes/ActionView/Helpers/AssetTagHelper.html#method-i-auto_discovery_link_tag) for more information.
58+
5559
#### favicon_link_tag
5660

5761
Returns a link tag for a favicon managed by the asset pipeline. The `source` can be a full path or a file that exists in your assets directory.
@@ -61,6 +65,8 @@ favicon_link_tag
6165
# => <link href="/assets/favicon.ico" rel="icon" type="image/x-icon" />
6266
```
6367

68+
See the [API Documentation](https://api.rubyonrails.org/classes/ActionView/Helpers/AssetTagHelper.html#method-i-favicon_link_tag) for more information.
69+
6470
#### image_path
6571

6672
Computes the path to an image asset in the `app/assets/images` directory. Full paths from the document root will be passed through. Used internally by `image_tag` to build the image path.
@@ -76,6 +82,8 @@ image_path("edit.png")
7682
# => /assets/edit-2d1a2db63fc738690021fedb5a65b68e.png
7783
```
7884

85+
See the [API Documentation](https://api.rubyonrails.org/classes/ActionView/Helpers/AssetUrlHelper.html#method-i-image_path) for more information.
86+
7987
#### image_url
8088

8189
Computes the URL to an image asset in the `app/assets/images` directory. This will call `image_path` internally and merge with your current host or your asset host.
@@ -84,6 +92,8 @@ Computes the URL to an image asset in the `app/assets/images` directory. This wi
8492
image_url("edit.png") # => http://www.example.com/assets/edit.png
8593
```
8694

95+
See the [API Documentation](https://api.rubyonrails.org/classes/ActionView/Helpers/AssetUrlHelper.html#method-i-image_url) for more information.
96+
8797
#### image_tag
8898

8999
Returns an HTML image tag for the source. The source can be a full path or a file that exists in your `app/assets/images` directory.
@@ -92,6 +102,8 @@ Returns an HTML image tag for the source. The source can be a full path or a fil
92102
image_tag("icon.png") # => <img src="/assets/icon.png" />
93103
```
94104

105+
See the [API Documentation](https://api.rubyonrails.org/classes/ActionView/Helpers/AssetTagHelper.html#method-i-image_tag) for more information.
106+
95107
#### javascript_include_tag
96108

97109
Returns an HTML script tag for each of the sources provided. You can pass in the filename (`.js` extension is optional) of JavaScript files that exist in your `app/assets/javascripts` directory for inclusion into the current page or you can pass the full path relative to your document root.
@@ -101,6 +113,8 @@ javascript_include_tag "common"
101113
# => <script src="/assets/common.js"></script>
102114
```
103115

116+
See the [API Documentation](https://api.rubyonrails.org/classes/ActionView/Helpers/AssetTagHelper.html#method-i-javascript_include_tag) for more information.
117+
104118
#### javascript_path
105119

106120
Computes the path to a JavaScript asset in the `app/assets/javascripts` directory. If the source filename has no extension, `.js` will be appended. Full paths from the document root will be passed through. Used internally by `javascript_include_tag` to build the script path.
@@ -109,6 +123,8 @@ Computes the path to a JavaScript asset in the `app/assets/javascripts` director
109123
javascript_path "common" # => /assets/common.js
110124
```
111125

126+
See the [API Documentation](https://api.rubyonrails.org/classes/ActionView/Helpers/AssetUrlHelper.html#method-i-javascript_path) for more information.
127+
112128
#### javascript_url
113129

114130
Computes the URL to a JavaScript asset in the `app/assets/javascripts` directory. This will call `javascript_path` internally and merge with your current host or your asset host.
@@ -118,6 +134,8 @@ javascript_url "common"
118134
# => http://www.example.com/assets/common.js
119135
```
120136

137+
See the [API Documentation](https://api.rubyonrails.org/classes/ActionView/Helpers/AssetUrlHelper.html#method-i-javascript_url) for more information.
138+
121139
#### picture_tag
122140

123141
Returns an HTML picture tag for the source. It supports passing a String, an Array or a Block.
@@ -136,6 +154,8 @@ This generates the following HTML:
136154
</picture>
137155
```
138156

157+
See the [API Documentation](https://api.rubyonrails.org/classes/ActionView/Helpers/AssetTagHelper.html#method-i-picture_tag) for more information.
158+
139159
#### preload_link_tag
140160

141161
Returns a link tag that browsers can use to preload the source. The source can be the path of a resource managed by asset pipeline, a full path, or an URI.
@@ -145,6 +165,8 @@ preload_link_tag "application.css"
145165
# => <link rel="preload" href="/assets/application.css" as="style" type="text/css" />
146166
```
147167

168+
See the [API Documentation](https://api.rubyonrails.org/classes/ActionView/Helpers/AssetTagHelper.html#method-i-preload_link_tag) for more information.
169+
148170
#### stylesheet_link_tag
149171

150172
Returns a stylesheet link tag for the sources specified as arguments. If you don't specify an extension, `.css` will be appended automatically.
@@ -154,6 +176,8 @@ stylesheet_link_tag "application"
154176
# => <link href="/assets/application.css" rel="stylesheet" />
155177
```
156178

179+
See the [API Documentation](https://api.rubyonrails.org/classes/ActionView/Helpers/AssetTagHelper.html#method-i-stylesheet_link_tag) for more information.
180+
157181
#### stylesheet_path
158182

159183
Computes the path to a stylesheet asset in the `app/assets/stylesheets` directory. If the source filename has no extension, `.css` will be appended. Full paths from the document root will be passed through. Used internally by `stylesheet_link_tag` to build the stylesheet path.
@@ -162,6 +186,8 @@ Computes the path to a stylesheet asset in the `app/assets/stylesheets` director
162186
stylesheet_path "application" # => /assets/application.css
163187
```
164188

189+
See the [API Documentation](https://api.rubyonrails.org/classes/ActionView/Helpers/AssetUrlHelper.html#method-i-stylesheet_path) for more information.
190+
165191
#### stylesheet_url
166192

167193
Computes the URL to a stylesheet asset in the `app/assets/stylesheets` directory. This will call `stylesheet_path` internally and merge with your current host or your asset host.
@@ -171,6 +197,8 @@ stylesheet_url "application"
171197
# => http://www.example.com/assets/application.css
172198
```
173199

200+
See the [API Documentation](https://api.rubyonrails.org/classes/ActionView/Helpers/AssetUrlHelper.html#method-i-stylesheet_path) for more information.
201+
174202
#### video_tag
175203

176204
Generate an HTML video tag with source(s), either as a single tag for a string source or nested source tags within an array for multiple sources. The `sources` can be full paths, files in your public videos directory, or Active Storage attachments.
@@ -180,6 +208,8 @@ video_tag("trailer")
180208
# => <video src="/videos/trailer"></video>
181209
```
182210

211+
See the [API Documentation](https://api.rubyonrails.org/classes/ActionView/Helpers/AssetTagHelper.html#method-i-video_tag) for more information.
212+
183213
### AtomFeedHelper
184214

185215
#### atom_feed
@@ -225,6 +255,8 @@ atom_feed do |feed|
225255
end
226256
```
227257

258+
See the [API Documentation](https://api.rubyonrails.org/classes/ActionView/Helpers/AtomFeedHelper.html#method-i-atom_feed) for more information.
259+
228260
### BenchmarkHelper
229261

230262
#### benchmark
@@ -239,6 +271,8 @@ Allows you to measure the execution time of a block in a template and records th
239271

240272
This would add something like "Process data files (0.34523)" to the log, which you can then use to compare timings when optimizing your code.
241273

274+
See the [API Documentation](https://api.rubyonrails.org/classes/ActiveSupport/Benchmarkable.html#method-i-benchmark) for more information.
275+
242276
### CacheHelper
243277

244278
#### cache
@@ -253,6 +287,8 @@ A method for caching fragments of a view rather than an entire action or page. T
253287

254288
[`AbstractController::Caching::Fragments`]: https://api.rubyonrails.org/classes/AbstractController/Caching/Fragments.html
255289

290+
See the [API Documentation](https://api.rubyonrails.org/classes/ActionView/Helpers/CacheHelper.html#method-i-cache) for more information.
291+
256292
### CaptureHelper
257293

258294
#### capture
@@ -278,6 +314,8 @@ The captured variable can then be used anywhere else.
278314
</html>
279315
```
280316

317+
See the [API Documentation](https://api.rubyonrails.org/classes/ActionView/Helpers/CaptureHelper.html#method-i-capture) for more information.
318+
281319
#### content_for
282320

283321
Calling `content_for` stores a block of markup in an identifier for later use. You can make subsequent calls to the stored content in other templates or the layout by passing the identifier as an argument to `yield`.
@@ -308,6 +346,8 @@ For example, let's say we have a standard application layout, but also a special
308346
<% end %>
309347
```
310348

349+
See the [API Documentation](https://api.rubyonrails.org/classes/ActionView/Helpers/CaptureHelper.html#method-i-content_for) for more information.
350+
311351
### DateHelper
312352

313353
#### distance_of_time_in_words
@@ -321,6 +361,8 @@ distance_of_time_in_words(Time.now, Time.now + 15.seconds, include_seconds: true
321361
# => less than 20 seconds
322362
```
323363

364+
See the [API Documentation](https://api.rubyonrails.org/classes/ActionView/Helpers/DateHelper.html#method-i-distance_of_time_in_words) for more information.
365+
324366
#### time_ago_in_words
325367

326368
Like `distance_of_time_in_words`, but where `to_time` is fixed to `Time.now`.
@@ -329,8 +371,12 @@ Like `distance_of_time_in_words`, but where `to_time` is fixed to `Time.now`.
329371
time_ago_in_words(3.minutes.from_now) # => 3 minutes
330372
```
331373

374+
See the [API Documentation](https://api.rubyonrails.org/classes/ActionView/Helpers/DateHelper.html#method-i-time_ago_in_words) for more information.
375+
332376
### DebugHelper
333377

378+
#### debug
379+
334380
Returns a `pre` tag that has object dumped by YAML. This creates a very readable way to inspect an object.
335381

336382
```ruby
@@ -349,6 +395,8 @@ third:
349395
</pre>
350396
```
351397

398+
See the [API Documentation](https://api.rubyonrails.org/classes/ActionView/Helpers/DebugHelper.html#method-i-debug) for more information.
399+
352400
### FormHelper
353401

354402
Form helpers are designed to make working with models much easier compared to using just standard HTML elements by providing a set of methods for creating forms based on your models. This helper generates the HTML for forms, providing a method for each sort of input (e.g., text, password, select, and so on). When the form is submitted (i.e., when the user hits the submit button or form.submit is called via JavaScript), the form inputs will be bundled into the params object and passed back to the controller.
@@ -380,6 +428,8 @@ alert('All is good')
380428
</script>
381429
```
382430

431+
See the [API Documentation](https://api.rubyonrails.org/classes/ActionView/Helpers/JavaScriptHelper.html#method-i-javascript_tag) for more information.
432+
383433
### NumberHelper
384434

385435
Provides methods for converting numbers into formatted strings. Methods are provided for phone numbers, currency, percentage, precision, positional notation, and file size.
@@ -392,6 +442,8 @@ Formats a number into a currency string (e.g., $13.65).
392442
number_to_currency(1234567890.50) # => $1,234,567,890.50
393443
```
394444

445+
See the [API Documentation](https://api.rubyonrails.org/classes/ActionView/Helpers/NumberHelper.html#method-i-number_to_currency) for more information.
446+
395447
#### number_to_human
396448

397449
Pretty prints (formats and approximates) a number so it is more readable by users; useful for numbers that can get very large.
@@ -401,6 +453,8 @@ number_to_human(1234) # => 1.23 Thousand
401453
number_to_human(1234567) # => 1.23 Million
402454
```
403455

456+
See the [API Documentation](https://api.rubyonrails.org/classes/ActionView/Helpers/NumberHelper.html#method-i-number_to_human) for more information.
457+
404458
#### number_to_human_size
405459

406460
Formats the bytes in size into a more understandable representation; useful for reporting file sizes to users.
@@ -410,6 +464,8 @@ number_to_human_size(1234) # => 1.21 KB
410464
number_to_human_size(1234567) # => 1.18 MB
411465
```
412466

467+
See the [API Documentation](https://api.rubyonrails.org/classes/ActionView/Helpers/NumberHelper.html#method-i-number_to_human_size) for more information.
468+
413469
#### number_to_percentage
414470

415471
Formats a number as a percentage string.
@@ -418,6 +474,8 @@ Formats a number as a percentage string.
418474
number_to_percentage(100, precision: 0) # => 100%
419475
```
420476

477+
See the [API Documentation](https://api.rubyonrails.org/classes/ActionView/Helpers/NumberHelper.html#method-i-number_to_percentage) for more information.
478+
421479
#### number_to_phone
422480

423481
Formats a number into a phone number (US by default).
@@ -426,6 +484,8 @@ Formats a number into a phone number (US by default).
426484
number_to_phone(1235551234) # => 123-555-1234
427485
```
428486

487+
See the [API Documentation](https://api.rubyonrails.org/classes/ActionView/Helpers/NumberHelper.html#method-i-number_to_phone) for more information.
488+
429489
#### number_with_delimiter
430490

431491
Formats a number with grouped thousands using a delimiter.
@@ -434,6 +494,8 @@ Formats a number with grouped thousands using a delimiter.
434494
number_with_delimiter(12345678) # => 12,345,678
435495
```
436496

497+
See the [API Documentation](https://api.rubyonrails.org/classes/ActionView/Helpers/NumberHelper.html#method-i-number_with_delimiter) for more information.
498+
437499
#### number_with_precision
438500

439501
Formats a number with the specified level of `precision`, which defaults to 3.
@@ -443,6 +505,8 @@ number_with_precision(111.2345) # => 111.235
443505
number_with_precision(111.2345, precision: 2) # => 111.23
444506
```
445507

508+
See the [API Documentation](https://api.rubyonrails.org/classes/ActionView/Helpers/NumberHelper.html#method-i-number_with_precision) for more information.
509+
446510
### SanitizeHelper
447511

448512
The SanitizeHelper module provides a set of methods for scrubbing text of undesired HTML elements.
@@ -469,10 +533,14 @@ class Application < Rails::Application
469533
end
470534
```
471535

536+
See the [API Documentation](https://api.rubyonrails.org/classes/ActionView/Helpers/SanitizeHelper.html#method-i-sanitize) for more information.
537+
472538
#### sanitize_css(style)
473539

474540
Sanitizes a block of CSS code.
475541

542+
See the [API Documentation](https://api.rubyonrails.org/classes/ActionView/Helpers/SanitizeHelper.html#method-i-sanitize_css) for more information.
543+
476544
#### strip_links(html)
477545

478546
Strips all link tags from text leaving just the link text.
@@ -492,6 +560,8 @@ strip_links('Blog: <a href="http://myblog.com/">Visit</a>.')
492560
# => Blog: Visit.
493561
```
494562

563+
See the [API Documentation](https://api.rubyonrails.org/classes/ActionView/Helpers/SanitizeHelper.html#method-i-strip_links) for more information.
564+
495565
#### strip_tags(html)
496566

497567
Strips all HTML tags from the html, including comments.
@@ -509,6 +579,8 @@ strip_tags("<b>Bold</b> no more! <a href='more.html'>See more</a>")
509579

510580
NB: The output may still contain unescaped '<', '>', '&' characters and confuse browsers.
511581

582+
See the [API Documentation](https://api.rubyonrails.org/classes/ActionView/Helpers/SanitizeHelper.html#method-i-strip_tags) for more information.
583+
512584
### UrlHelper
513585

514586
Provides methods to make links and get URLs that depend on the routing subsystem.
@@ -562,7 +634,7 @@ would output:
562634
</a>
563635
```
564636

565-
See [the API Documentation for more information](https://api.rubyonrails.org/classes/ActionView/Helpers/UrlHelper.html#method-i-link_to)
637+
See the [API Documentation](https://api.rubyonrails.org/classes/ActionView/Helpers/UrlHelper.html#method-i-link_to) for more information.
566638

567639
#### button_to
568640

@@ -583,7 +655,7 @@ would roughly output something like:
583655
</form>
584656
```
585657

586-
See [the API Documentation for more information](https://api.rubyonrails.org/classes/ActionView/Helpers/UrlHelper.html#method-i-button_to)
658+
See the [API Documentation](https://api.rubyonrails.org/classes/ActionView/Helpers/UrlHelper.html#method-i-button_to) for more information.
587659

588660
### CsrfHelper
589661

0 commit comments

Comments
 (0)