Replies: 2 comments 1 reply
-
Might be worth mentioning, the above examples were tested with |
Beta Was this translation helpful? Give feedback.
-
The long-term goal is to move away from using Rails tag helpers — since they’re not as safe as Phlex tags. In the meantime, you have a few options:
def template
unsafe_raw helpers.submit_tag 'Hi', class: 'border-2 border-red-500'
unsafe_raw helpers.submit_tag 'Ho', class: 'border-2 border-green-500'
end
user_profile = "javascript:alert(1)"
unsafe_raw link_to "Test", user_profile
include Phlex::Rails::Helpers::FormWith
def template
form_with do |f|
f.submit 'Hi', class: 'border-2 border-red-500'
f.submit 'Ho', class: 'border-2 border-green-500'
end
end
def template
input(type: "submit", class: 'border-2 border-red-500') { 'Hi' }
input(type: "submit", class: 'border-2 border-green-500') { 'Ho' }
end Ultimately this is the best and safest option, but there's some work to do to make it easier. Rails form helpers include authenticity tokens automatically, for example. I would like to build helpers specifically for Phlex/Rails that do the same things. |
Beta Was this translation helpful? Give feedback.
-
It's a little bit hard to use Rails' built-in helpers because of their way of not just returning strings (🙄)
Some examples
I know some methods are wrapped. Could we wrap all of them? Or provide some other method of making sense of this? At the very least, I think we should add a page to the docs about this with examples.
I'll be happy to contribute such a page when I've tried and tested some more, if necessary.
Beta Was this translation helpful? Give feedback.
All reactions