From e61c4b353d4ddf0d9d56ef98a7a1bb67f8966b8e Mon Sep 17 00:00:00 2001 From: Akhil G Krishnan Date: Sun, 26 Nov 2023 10:51:39 +0530 Subject: [PATCH] Add link to API documentation for ActionView helper method --- guides/source/action_view_helpers.md | 76 +++++++++++++++++++++++++++- 1 file changed, 74 insertions(+), 2 deletions(-) diff --git a/guides/source/action_view_helpers.md b/guides/source/action_view_helpers.md index 5348dea469..51b612ea4b 100644 --- a/guides/source/action_view_helpers.md +++ b/guides/source/action_view_helpers.md @@ -43,6 +43,8 @@ audio_tag("sound") # => ``` +See the [API Documentation](https://api.rubyonrails.org/classes/ActionView/Helpers/AssetTagHelper.html#method-i-audio_tag) for more information. + #### auto_discovery_link_tag 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 # => ``` +See the [API Documentation](https://api.rubyonrails.org/classes/ActionView/Helpers/AssetTagHelper.html#method-i-auto_discovery_link_tag) for more information. + #### favicon_link_tag 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 # => ``` +See the [API Documentation](https://api.rubyonrails.org/classes/ActionView/Helpers/AssetTagHelper.html#method-i-favicon_link_tag) for more information. + #### image_path 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") # => /assets/edit-2d1a2db63fc738690021fedb5a65b68e.png ``` +See the [API Documentation](https://api.rubyonrails.org/classes/ActionView/Helpers/AssetUrlHelper.html#method-i-image_path) for more information. + #### image_url 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 image_url("edit.png") # => http://www.example.com/assets/edit.png ``` +See the [API Documentation](https://api.rubyonrails.org/classes/ActionView/Helpers/AssetUrlHelper.html#method-i-image_url) for more information. + #### image_tag 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 image_tag("icon.png") # => ``` +See the [API Documentation](https://api.rubyonrails.org/classes/ActionView/Helpers/AssetTagHelper.html#method-i-image_tag) for more information. + #### javascript_include_tag 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" # => ``` +See the [API Documentation](https://api.rubyonrails.org/classes/ActionView/Helpers/AssetTagHelper.html#method-i-javascript_include_tag) for more information. + #### javascript_path 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 javascript_path "common" # => /assets/common.js ``` +See the [API Documentation](https://api.rubyonrails.org/classes/ActionView/Helpers/AssetUrlHelper.html#method-i-javascript_path) for more information. + #### javascript_url 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" # => http://www.example.com/assets/common.js ``` +See the [API Documentation](https://api.rubyonrails.org/classes/ActionView/Helpers/AssetUrlHelper.html#method-i-javascript_url) for more information. + #### picture_tag 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: ``` +See the [API Documentation](https://api.rubyonrails.org/classes/ActionView/Helpers/AssetTagHelper.html#method-i-picture_tag) for more information. + #### preload_link_tag 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" # => ``` +See the [API Documentation](https://api.rubyonrails.org/classes/ActionView/Helpers/AssetTagHelper.html#method-i-preload_link_tag) for more information. + #### stylesheet_link_tag 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" # => ``` +See the [API Documentation](https://api.rubyonrails.org/classes/ActionView/Helpers/AssetTagHelper.html#method-i-stylesheet_link_tag) for more information. + #### stylesheet_path 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 stylesheet_path "application" # => /assets/application.css ``` +See the [API Documentation](https://api.rubyonrails.org/classes/ActionView/Helpers/AssetUrlHelper.html#method-i-stylesheet_path) for more information. + #### stylesheet_url 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" # => http://www.example.com/assets/application.css ``` +See the [API Documentation](https://api.rubyonrails.org/classes/ActionView/Helpers/AssetUrlHelper.html#method-i-stylesheet_path) for more information. + #### video_tag 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") # => ``` +See the [API Documentation](https://api.rubyonrails.org/classes/ActionView/Helpers/AssetTagHelper.html#method-i-video_tag) for more information. + ### AtomFeedHelper #### atom_feed @@ -225,6 +255,8 @@ atom_feed do |feed| end ``` +See the [API Documentation](https://api.rubyonrails.org/classes/ActionView/Helpers/AtomFeedHelper.html#method-i-atom_feed) for more information. + ### BenchmarkHelper #### benchmark @@ -239,6 +271,8 @@ Allows you to measure the execution time of a block in a template and records th 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. +See the [API Documentation](https://api.rubyonrails.org/classes/ActiveSupport/Benchmarkable.html#method-i-benchmark) for more information. + ### CacheHelper #### cache @@ -253,6 +287,8 @@ A method for caching fragments of a view rather than an entire action or page. T [`AbstractController::Caching::Fragments`]: https://api.rubyonrails.org/classes/AbstractController/Caching/Fragments.html +See the [API Documentation](https://api.rubyonrails.org/classes/ActionView/Helpers/CacheHelper.html#method-i-cache) for more information. + ### CaptureHelper #### capture @@ -278,6 +314,8 @@ The captured variable can then be used anywhere else. ``` +See the [API Documentation](https://api.rubyonrails.org/classes/ActionView/Helpers/CaptureHelper.html#method-i-capture) for more information. + #### content_for 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 <% end %> ``` +See the [API Documentation](https://api.rubyonrails.org/classes/ActionView/Helpers/CaptureHelper.html#method-i-content_for) for more information. + ### DateHelper #### distance_of_time_in_words @@ -321,6 +361,8 @@ distance_of_time_in_words(Time.now, Time.now + 15.seconds, include_seconds: true # => less than 20 seconds ``` +See the [API Documentation](https://api.rubyonrails.org/classes/ActionView/Helpers/DateHelper.html#method-i-distance_of_time_in_words) for more information. + #### time_ago_in_words 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`. time_ago_in_words(3.minutes.from_now) # => 3 minutes ``` +See the [API Documentation](https://api.rubyonrails.org/classes/ActionView/Helpers/DateHelper.html#method-i-time_ago_in_words) for more information. + ### DebugHelper +#### debug + Returns a `pre` tag that has object dumped by YAML. This creates a very readable way to inspect an object. ```ruby @@ -349,6 +395,8 @@ third: ``` +See the [API Documentation](https://api.rubyonrails.org/classes/ActionView/Helpers/DebugHelper.html#method-i-debug) for more information. + ### FormHelper 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') ``` +See the [API Documentation](https://api.rubyonrails.org/classes/ActionView/Helpers/JavaScriptHelper.html#method-i-javascript_tag) for more information. + ### NumberHelper 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). number_to_currency(1234567890.50) # => $1,234,567,890.50 ``` +See the [API Documentation](https://api.rubyonrails.org/classes/ActionView/Helpers/NumberHelper.html#method-i-number_to_currency) for more information. + #### number_to_human 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 number_to_human(1234567) # => 1.23 Million ``` +See the [API Documentation](https://api.rubyonrails.org/classes/ActionView/Helpers/NumberHelper.html#method-i-number_to_human) for more information. + #### number_to_human_size 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 number_to_human_size(1234567) # => 1.18 MB ``` +See the [API Documentation](https://api.rubyonrails.org/classes/ActionView/Helpers/NumberHelper.html#method-i-number_to_human_size) for more information. + #### number_to_percentage Formats a number as a percentage string. @@ -418,6 +474,8 @@ Formats a number as a percentage string. number_to_percentage(100, precision: 0) # => 100% ``` +See the [API Documentation](https://api.rubyonrails.org/classes/ActionView/Helpers/NumberHelper.html#method-i-number_to_percentage) for more information. + #### number_to_phone Formats a number into a phone number (US by default). @@ -426,6 +484,8 @@ Formats a number into a phone number (US by default). number_to_phone(1235551234) # => 123-555-1234 ``` +See the [API Documentation](https://api.rubyonrails.org/classes/ActionView/Helpers/NumberHelper.html#method-i-number_to_phone) for more information. + #### number_with_delimiter Formats a number with grouped thousands using a delimiter. @@ -434,6 +494,8 @@ Formats a number with grouped thousands using a delimiter. number_with_delimiter(12345678) # => 12,345,678 ``` +See the [API Documentation](https://api.rubyonrails.org/classes/ActionView/Helpers/NumberHelper.html#method-i-number_with_delimiter) for more information. + #### number_with_precision Formats a number with the specified level of `precision`, which defaults to 3. @@ -443,6 +505,8 @@ number_with_precision(111.2345) # => 111.235 number_with_precision(111.2345, precision: 2) # => 111.23 ``` +See the [API Documentation](https://api.rubyonrails.org/classes/ActionView/Helpers/NumberHelper.html#method-i-number_with_precision) for more information. + ### SanitizeHelper The SanitizeHelper module provides a set of methods for scrubbing text of undesired HTML elements. @@ -469,10 +533,14 @@ class Application < Rails::Application end ``` +See the [API Documentation](https://api.rubyonrails.org/classes/ActionView/Helpers/SanitizeHelper.html#method-i-sanitize) for more information. + #### sanitize_css(style) Sanitizes a block of CSS code. +See the [API Documentation](https://api.rubyonrails.org/classes/ActionView/Helpers/SanitizeHelper.html#method-i-sanitize_css) for more information. + #### strip_links(html) Strips all link tags from text leaving just the link text. @@ -492,6 +560,8 @@ strip_links('Blog: Visit.') # => Blog: Visit. ``` +See the [API Documentation](https://api.rubyonrails.org/classes/ActionView/Helpers/SanitizeHelper.html#method-i-strip_links) for more information. + #### strip_tags(html) Strips all HTML tags from the html, including comments. @@ -509,6 +579,8 @@ strip_tags("Bold no more! See more") NB: The output may still contain unescaped '<', '>', '&' characters and confuse browsers. +See the [API Documentation](https://api.rubyonrails.org/classes/ActionView/Helpers/SanitizeHelper.html#method-i-strip_tags) for more information. + ### UrlHelper Provides methods to make links and get URLs that depend on the routing subsystem. @@ -562,7 +634,7 @@ would output: ``` -See [the API Documentation for more information](https://api.rubyonrails.org/classes/ActionView/Helpers/UrlHelper.html#method-i-link_to) +See the [API Documentation](https://api.rubyonrails.org/classes/ActionView/Helpers/UrlHelper.html#method-i-link_to) for more information. #### button_to @@ -583,7 +655,7 @@ would roughly output something like: ``` -See [the API Documentation for more information](https://api.rubyonrails.org/classes/ActionView/Helpers/UrlHelper.html#method-i-button_to) +See the [API Documentation](https://api.rubyonrails.org/classes/ActionView/Helpers/UrlHelper.html#method-i-button_to) for more information. ### CsrfHelper