博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
rails 字符串 转化为 html
阅读量:6306 次
发布时间:2019-06-22

本文共 1124 字,大约阅读时间需要 3 分钟。

simple_format              http://apidock.com/rails/v4.0.2/ActionView/Helpers/TextHelper/simple_formathttp://api.rubyonrails.org/classes/ActionView/Helpers/TextHelper.htmlmy_text = "Here is some basic text...\n...with a line break."simple_format(my_text)# => "

Here is some basic text...\n

...with a line break.

"simple_format(my_text, {}, wrapper_tag: "div")# => "
Here is some basic text...\n
...with a line break.
"more_text = "We want to put a paragraph...\n\n...right there."simple_format(more_text)# => "

We want to put a paragraph...

\n\n

...right there.

"simple_format("Look ma! A class!", class: 'description')# => "

Look ma! A class!

"simple_format("
Unblinkable.
")# => "

Unblinkable.

"simple_format("
Blinkable!
It's true.", {}, sanitize: false)# => "

Blinkable! It's true.

"一个\n被认为是换行其之后是
两个\n被认为是分段其之前是

之后

If you want to escape all content, you should invoke the h method before calling the text helper.simple_format h('Example')# => "

<a href=\"http://example.com/\">Example</a>

"

 

转载于:https://www.cnblogs.com/znsongshu/p/6080217.html

你可能感兴趣的文章
《Flask Web开发》里的坑
查看>>
Python-库安装
查看>>
Git笔记
查看>>
普通人如何从平庸到优秀,在到卓越
查看>>
SLAM数据集
查看>>
c#学习笔记05——数组&集合
查看>>
【图论算法】Dijstra&BFS
查看>>
注册和上传文件(头像)
查看>>
使用OVS
查看>>
键盘回收的几种方法
查看>>
Python(条件判断和循环)
查看>>
day4 linux安装python
查看>>
LeetCode Container With Most Water (Two Pointers)
查看>>
vue (v-if show 问题)
查看>>
https基础
查看>>
css3 canvas之刮刮卡效果
查看>>
并查集模板
查看>>
RESTful Mongodb
查看>>
BZOJ3237:[AHOI2013]连通图(线段树分治,并查集)
查看>>
如何提高Ajax性能
查看>>