-
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
Slim templates conversion broken #120
Comments
I'm having the same issue. I upgraded from deface 0.9.1 to 1.0.0 and the conversion from Slim to ERB seems to be completely broken. Lots of templates are simply broken while others treat the code as being escaped (so you see things like 'if user' in the view. |
@Jaco-Pretorius Can you show us an app which clearly reproduces this issue please? |
@radar I'll try to put one together |
@radar I created an example that shows both the problems I am having: https://github.com/Jaco-Pretorius/deface-slim-bug-example Look at the _nav_bar.html.slim template - when you run the server you should get an error saying the erb is malformed, I suspect this is with the conversion from slim to erb. Now if you look at that template and comment out everything from line 11 onwards you won't get a syntax error, but you will see the interpolation syntax on the page itself (being escaped incorrectly). That's the 2 issues I'm having. Let me know if what I wrote makes any sense at all. |
I did a git bisect with my example against the deface gem (meaning I'm searching through the deface commits to find the commit that broke my example). The culprit is this one: 415422f (no surprise, this seems to be the biggest change between 0.9.1 and 1.0.0. I'm trying to do more digging to figure out what is going wrong. |
Ok, this is what is going on. The change from
|
@Jaco-Pretorius is there a short-term fix for this that you know about? I've got an issue where this is completely mangling a couple of my pages. |
@wingrunr21 AFAIK you can switch off deface for slim completely in the config, but I haven't tried it. Unfortunately I'm no longer on the project where we had this issue. |
@wingrunr21 this issue appears to be fixed with the latest version of Nokogiri (v.1.6.2.1). We are using Slim templates in our project and after we did a bundle update there are no longer any issues with Deface. Here's the updated repo showing the problem being fixed in Nokogiri v1.6.2.1: |
After deploying to Heroku, this issue has popped up again. It seems that this issue depends on both the Nokogiri version and the libxml version it is compiled against. In Heroku the libxml version appears to be locked at 2.7.6 whereas our local development environment uses 2.8.0. With 2.8.0 this issue seems to be resolved:
More information on Heroku locking libxml to 2.7.6: To workaround this issue for now:
|
I actually saw the issue in a slim view that was being rendered directly, not via a Deface override. Good information on the libxml version though. I'm guessing Heroku pre-builds Nokogiri since it is such a common gem and Bundler thus uses the pre-built version. |
@wingrunr21 You mentioned your issue was in a slim view that was being rendered directly. Which view in particular? A slim template will break due to Deface if an override is linked to that template, even if that override doesn't actually result in any changes. So it's not just the "inserted" view that could break, it's also the original view that is being "overridden". |
It was completely overridden view for products |
Also having the same issue, I overrode "spree/orders/edit" with slim in a spree 1.2 app and the form contents are escaped: Slim: == form_tag empty_cart_path, method: :put, id: 'emptycart' do
= submit_tag t('empty_cart') Html: (formatted for your sanity) <form accept-charset="UTF-8" action="/cart/empty" id="emptycart" method="post">
<div style="margin:0;padding:0;display:inline">
<input name="utf8" type="hidden" value="✓" />
<input name="_method" type="hidden" value="put" />
<input name="authenticity_token" type="hidden" value="E9OW9sLa2T6sqaziF0+b2LYH/Z7EeLeRsDKaDLslFDA=" />
</div>
<input name="commit" type="submit" value="Empty Cart" />
</form> This is happening on my local mechine in
And I still get the same error if I install using nokogiri the system library (not the shipped version) like this: gem uninstall nokogiri
gem install nokogiri -- --use-system-libraries
bundle exec nokogiri -v
# Nokogiri (1.6.2.1)
---
warnings: []
nokogiri: 1.6.2.1
ruby:
version: 2.1.2
platform: x86_64-linux
description: ruby 2.1.2p95 (2014-05-08 revision 45877) [x86_64-linux]
engine: ruby
libxml:
binding: extension
source: system
compiled: 2.9.1
loaded: 2.9.1 Here is the output from the dev log for that page:
As you can see I have tried disabling the two overrides but this didn't help. Just a note this code slim does work like you would expect... but its really ugly: - f = form_tag empty_cart_path, method: :put, id: 'emptycart' do
= submit_tag t('empty_cart')
= f.html_safe |
It's being a while since last post here, did you guys found a solution? I'm still having this same issue that you described here. |
I pushed a couple of Slim related fixes to master, which should also hopefully solve the problems described here. Please open a new issue with the exact slim syntax if you're still having problems. |
Hi, the error I was having is still happening with master. I have opened a new issue with more details at #133 thanks :) |
Hi,
There is a problem when using blocks and slim.
This will result in the block content being escaped and presented uninterpreted.
Also some other slim templates are raising syntax errors. I had to downgrade to 9.1
Is there a way to disable deface for slim templates ?
rails 3.2 / spree 1.3 / ruby 2.0 / deface 1.0.0 / slim 2.0.1 and 2.0.2
The text was updated successfully, but these errors were encountered: