LoginSignup
1
0

More than 3 years have passed since last update.

【Rails】js.erb で文字列の途中で改行する方法

Posted at

背景

JSにRubyを埋め込みしていたのですが、長ったらしくなってしまったので、途中で改行したくなりました。

方法

行の最後に「\」をつける。

document.getElementById('messages').insertAdjacentHTML('afterbegin',
'<p id="<%= @message.id %>">\
    <span><%= @message.content %></span>\
    <span><%= @message.user.name %></span>\
    <span><%= @message.created_at %></span>\
 </p>');

「\」の入力方法は、macなら「option」+ 「¥」

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0