Skip to content
Discussion options

You must be logged in to vote

I believe Phlex will render the to_s of anything that extends Phlex::SGML::SafeObject implicitly. So you can omit the raw call in your example as long as it's the only thing in the block.

p do
  t(:contact_support)
end

If there’s something else in the block, you would have to use raw.

p do
  plain "Please contact "
  raw t(:contact_support)
end

A few options for the other bit:

  1. you could rewrite your t method to return the output of safe;
  2. you could include Phlex::SGML::SafeObject into your HTMLSafeString class; or
  3. you could use Phlex::SGML::SafeValue instead of your HTMLSafeString, which is essentially the same thing. You can see the implementation here and all safe is doing is returning …

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@davetron5000
Comment options

Answer selected by davetron5000
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Help
Labels
None yet
2 participants