新手问题 在 views 内 show.html.haml 文件下,如何将输入的 html 格式的 content 输出为 haml 格式

yehualiu · 2014年04月17日 · 最后由 yehualiu 回复于 2014年04月17日 · 2457 次阅读

这是_form.html.haml 的部分代码

%div
      = f.label :content, "内容"
      %br/
      = f.text_area :content, style: "height: 500px", class: "wysihtml5"
      :javascript
        $(document).ready(function(){
          $('.wysihtml5').wysihtml5({
            "size": 'tiny',
            "font-styles": false, //Font styling, e.g. h1, h2, etc. Default true
            "emphasis": true, //Italics, bold, etc. Default true
            "lists": false, //(Un)ordered lists, e.g. Bullets, Numbers. Default true
            "html": false, //Button which allows you to edit the generated HTML. Default false
            "link": true, //Button to insert a link. Default true
            "color": true, //Button to change color of font
            "image": true, //Button to insert an image. Default true,
            "locale": "zh-CN"
          });
        })

这是 show.html.haml 的部分代码

%h5= @article.content              (关键是这里怎么改)

谢谢,大牛

为什么要这么做?

#1 楼 @Rei 不然在 show 页面直接输出

ljkljkl80909

没有进行 haml 转码,不能正常显示

%h5= sanitize @article.content

如果发现有些需要的标签被过滤了,看这里 http://api.rubyonrails.org/classes/ActionView/Helpers/SanitizeHelper.html

需要 登录 后方可回复, 如果你还没有账号请 注册新账号