-
Notifications
You must be signed in to change notification settings - Fork 127
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
html escaping when using slim + deface (related to #120) #133
Comments
Hey @complistic-gaff , |
@joshblour, I gave up soon after I made this issue and I'm only using erb where I need to use blocks. You could store the content in a variable and then render it later like in my last example... though it's very ugly. The core of the issue is that content from blocks like
One other way I see of fixing the "problem" would be not to convert the template to erb at all if all of it's overrides are disabled. This would allow you to disable all the overrides and just replace the whole template with a slim one. Or even a global "disable deface on slim" might work also. |
curious if there's any movement on this one? thx!! |
This is probably not an acceptable workaround for most folks, but since I never use Deface, I just disabled it globally in development.rb, test.rb, and production.rb, by adding this line:
|
Same problem with me rails 4.2-stable BTW, @complistic-gaff how does the solution work?(I mean, ugly one). Could you explain this, plz? |
Same with me. But seems i found the issue. Cache. Try clear the cache. |
Dropping the following monkey patch into Rails initializers helped me out: require 'slim/erb_converter'
module Deface
class SlimConverter
def initialize(template, options = {})
@template = template
end
def result
conv = if defined?(Slim::RailsTemplate)
::Slim::ERBConverter.new(Slim::RailsTemplate.options)
else
::Slim::ERBConverter.new
end
conv.call(@template).gsub(/<%\s*%>/, '')
end
end
end It seems like in the original version the offending Gosh, it took me an extensive debugging session to figure out! |
Rails SLIM capturing support, addresses issue #133
When overriding an erb template that has an override with a slim template, the html content from blocks (like
form_for
) is escaped.This issue was happening to me a few months ago when I upgraded to Deface 1.0 and is still happening with latest fixes in master.
I have a feeling it's related to the change from code to erb tags as pointed out in #120
When working on a spree application, if you override the
orders/edit
with the following content:app/views/spree/orders/edit.html.slim
It will produce the following html:
My system is as follows:
I have tried nokogiri with packaged libxml-2.8.0 and also system libxml-2.9.1 as suggested in #120 but it does not make any difference.
I have also tried disabling all deface overrides that affect that page with no luck.
(Note pages that do not have any deface overrides work as expected)
I have also tried to force raw and
html_safe
content in the template but this didn't help:However the following template works as you would expect (but is ugly):
Thanks for all your help :)
The text was updated successfully, but these errors were encountered: