Rails 문자열, 숫자 관련 뷰 헬퍼4

rails·2021년 11월 9일
0

Rails 튜토리얼

목록 보기
10/11

Rails 문자열, 숫자 관련 뷰 헬퍼4

image_tag(src) 메소드

  • src : 그림 파일의 경로 (절대 경로 또는 /app/assets/images 상대경로)
<%= image_tag 'test1.gif' %>

혹은

<%= image_tag 'https://www.test.com/image/link1.png' %>

대부분의 레일즈 뷰헬퍼가 그렇듯이 아래처럼 옵션을 주는 것도 가능 하다.

<%= image_tag 'https://www.test.com/image/link1.png', size: '190x100' %>

audio_tag(src) 메소드 (HTML5)

  • src : 그림 파일의 경로 (절대 경로 또는 /app/assets/images 상대경로)
<%= audio_tag 'test1.wav' %>

오디오 재생 관련 옵션을 넣는다면

<%= audio_tag 'test1.wav', autoplay: false, controls: true %>

video_tag 메소드 (HTML5)

  • 위 오디오 태그와 유사하지만 비디오를 다룬다.
<%= video_tag 'test1.mp4' %>

비디오 재생 관련 옵션을 넣는다면

<%= video_tag 'test1.mp4', controls: true, autoplay: false, loop: true, size: '300x150', poster: 'logo.png' %>

auto_discovery_link_tag 메소드

  • 브라우저에서 RSS피드를 자동 검출 한다.
<%= auto_discovery_link_tag(:rss, { controller: :posts, actions: :index }) %>

favicon_link_tag 메소드

  • Favicon이란 Favorite icon의 줄임말로 사이트의 상징 아이콘을 말한다. 예를 들어 벨로그라면 아래 같은 작은 아이콘이다.
<%= favicon_link_tag 'favicon.ico', type: 'image/png' %>

path_to_javascript 메소드

  • 외부 자바스크립트 경로를 자동 추출 한다.
<%= path_to_javascript 'test.js' %>

path_to_stylesheet 메소드

  • 외부 스타일시트 경로를 자동 추출 한다.
<%= path_to_stylesheet 'test.css' %>

path_to_audio 메소드

  • 외부 오디오파일 경로를 자동 추출 한다.
<%= path_to_audio 'test.mp3' %>

path_to_video 메소드

  • 외부 비디오 경로를 자동 추출 한다.
<%= path_to_video 'test.mp4' %>

path_to_image 메소드

  • 외부 이미지 경로를 자동 추출 한다.
<%= path_to_image 'test.png' %>
profile
rails

0개의 댓글