【发布时间】:2012-11-14 16:54:06
【问题描述】:
我正在为我的应用程序使用bootstrap-wysihtml5 gem,这是一个所见即所得的表单文本编辑器。 当我在文本区域中输入类似这样的内容时:
“这是一个测试,看看 bold 和 italic 是否有效”
我认为这是:
"this is a test to see if **bold** and *italic* are working"
任何 html 都显示为代码,而不是呈现为格式化文本。 似乎格式正在被编码,它只是没有正确呈现。 这可能是什么原因造成的?
我的代码如下,紧跟自述文件。
posts/_form.html.erb
<%= form_for @post, :html => { :multipart => true } do |f| %>
<%= f.label :content %>
<%= f.text_area :content, :class => 'wysihtml5' %>
<%= f.label :photo %>
<%= f.file_field :photo %>
<script type="text/javascript">
$('.wysihtml5').each(function(i, elem) {
$(elem).wysihtml5();
});
</script>
<div class="actions">
<%= f.submit %>
</div>
<% end %>
posts/_post.html.erb
<div class="photo"><%= image_tag post.photo.url %></div>
<div class="content"><%= post.content %></div>
【问题讨论】:
标签: javascript ruby-on-rails ruby-on-rails-3