Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
297 views
in Technique[技术] by (71.8m points)

ruby on rails - Action Text displaying html tags

I'm using Action Text in order to create articles and display well the content of it. But I have a problem, when I create my article then display the content it's showing the HTML tags. Here : enter image description here

Here is my code :

articles/show.html.erb :

<%= @article.body %>

application.scss:

@import "trix/dist/trix";
@import "./actiontext.scss";

_form.html.erb:

<%= form_for @article do |f| %>
<%= f.rich_text_area :body, height: "300px", width:"300px" %>
<%= end %>

application.js :

//= require actiontext
require("trix")
require("@rails/actiontext")

actiontext.scss:

.trix-content {
  .attachment-gallery {
    > action-text-attachment,
    > .attachment {
      flex: 1 0 33%;
      padding: 0 0.5em;
      max-width: 33%;
    }

    &.attachment-gallery--2,
    &.attachment-gallery--4 {
      > action-text-attachment,
      > .attachment {
        flex-basis: 50%;
        max-width: 50%;
      }
    }
  }

  action-text-attachment {
    .attachment {
      padding: 0 !important;
      max-width: 100% !important;
    }
  }
}

Does anyone got any idea ?

question from:https://stackoverflow.com/questions/65916336/action-text-displaying-html-tags

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Well I don't know why action text are showing the HTML balise but maybe using SanitizeHelper would help you to remove the balises.

We use it in our project after having a similar problem.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

2.1m questions

2.1m answers

60 comments

57.0k users

...