Questions tagged [html-safe]

75 questions
3
votes
1 answer

How to create a Rails-specific Rubygem?

We're building a Chat service, which people are able to use from within their code. Amongst the tools we're building, we've made a Ruby gem to allow people to quickly add a Chat window to their Ruby web-application. We'd like to create a…
Qqwy
  • 5,214
  • 5
  • 42
  • 83
3
votes
1 answer

content_tag not working with f.submit on rails 5.1

I would like to add a bootstrap styling to my f.submit button with ruby on rails form helpers. But the code below not working for me. Does anyone have an idea how to do this correctly with rails 5.1? <%= f.submit content_tag(:i, "Add to Cart",…
Lucy
  • 31
  • 1
3
votes
1 answer

how to use html_safe in meta tag og:description content in ruby on rails

I use og:description meta tag like this But it shows description of post in top of the page.
Md. Sahidul Islam
  • 351
  • 1
  • 3
  • 14
3
votes
2 answers

render html from javascript rails

I Have a rendering of a partial that should be outputted to a div that is not displayed correctly. I tried in my index.js.haml : = "$('.modal-body').html('#{escape_javascript(raw render("details"))}');" =…
lguenier
  • 187
  • 1
  • 10
3
votes
4 answers

Are truncate and raw mutually exclusive methods in ruby?

I am trying to do this truncate raw(@some_text), length: 300 . When the text exceeds the limit of 300 characters I see html tags in the text. I need to truncate and implement html(tags prepended and appended) properties in the text. Is there any…
railer
  • 97
  • 7
2
votes
1 answer

Messy " returned from Rails 3 controller to view

On my Rails 3 app controller I have the following code: array = [] Location.all.each{|x|array<
JZ.
  • 21,147
  • 32
  • 115
  • 192
2
votes
3 answers

html_safe with undefined fields

i have a field which is not required i.e. can be nil. i want to use the ffg: myfield.html_safe in my view. this doesn't work for the items that have no myfield. i get an exception, how do i get html_safe to apply only if the field is defined? thanks
newbie_86
  • 4,520
  • 17
  • 58
  • 89
2
votes
1 answer

Format html content from database using prawn

How can render HTML content from database in a prawn document class PdfReport < Prawn::Document def initialize user super() text user.description #=> "

It's an html content

" end end The output i am getting from the above code is a…
webster
  • 3,902
  • 6
  • 37
  • 59
2
votes
1 answer

html_safe not working in link_to title property in rails

I would like to display tool tip with rich text as like below <%= link_to 'test', '#', :title => "sample".html_safe %> its not working and displaying with html tags. Want to display html formatted text without html tags in anchor title…
Raju akula
  • 1,255
  • 1
  • 13
  • 18
2
votes
1 answer

best_in_place and html_safe

I'm using the best_in_place gem in my rails app to allow for inline editing. I'm running into issues with trying to render some text html safe. Without specifying that the text should be made html_safe, this is what it looks like on the page: I…
scientiffic
  • 9,045
  • 18
  • 76
  • 149
2
votes
3 answers

django template renders "<bound method.." instead of context variables

I've got a template 'cart_summary.html' which renders fine when I it appears as an include on another template {% include 'cart/cart_summary.html' %}. However when I render it directly from a view function (called by ajax), my context variables do…
Aidan Ewen
  • 13,049
  • 8
  • 63
  • 88
2
votes
2 answers

Mark ActiveRecord attribute as html_safe

We have an ActiveRecord model with an html attribute (say Post#body). Is there a nice way that calling body on a post returns an html_safe? string? E.g.: class Post < ActiveRecord::Base # is_html_escaped :body or somesuch…
Marc-André Lafortune
  • 78,216
  • 16
  • 166
  • 166
1
vote
1 answer

rails to_json.html_safe Uncaught SyntaxError: Unexpected identifier

I have in my stock rails 3.1 app's projects#index.html.erb a javascript section to reads like this: