Skip to content

Commit 07ed4f8

Browse files
Add picture_tag to ActionView helpers guides [ci skip]
1 parent 4161ae7 commit 07ed4f8

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

guides/source/action_view_helpers.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,24 @@ javascript_url "common"
9999
# => http://www.example.com/assets/common.js
100100
```
101101

102+
#### picture_tag
103+
104+
Returns an HTML picture tag for the source. It supports passing a String, an Array or a Block.
105+
106+
```ruby
107+
picture_tag("icon.webp", "icon.png")
108+
```
109+
110+
This generates the following HTML:
111+
112+
```html
113+
<picture>
114+
<source srcset="/assets/icon.webp" type="image/webp" />
115+
<source srcset="/assets/icon.png" type="image/png" />
116+
<img src="/assets/icon.png" />
117+
</picture>
118+
```
119+
102120
#### preload_link_tag
103121

104122
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.

0 commit comments

Comments
 (0)