开发者

Correct display of a string

开发者 https://www.devze.com 2023-01-03 15:22 出处:网络
How to display a string in correct format as i enter it in the textarea in ruby on rails? actually i enter some string in the textarea as:
  • How to display a string in correct format as i enter it in the textarea in ruby on rails?

  • actually i enter some string in the textarea as:

    my name

    is jamal.

  • now there is a next line starting after name... but i get the following in the view...

    my name is jamal

  • which i don't want to be lik开发者_运维知识库e that... so, how to get the correct format..?

  • i hope u understand...


take a look at simple_format method

i.e. <%= simple_format(params[:text]) %> or <%= simple_format(@text) %> in your erb/rhtml view code


If you're including the string within a textarea in the view then that is odd. However, if you are just printing the string to the page, then you will need to replace newline characters with "<br/>" tags.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号