-
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
Jruby: output not properly converted back to erb #74
Comments
That's interesting, I'll have a play with JRuby and see if I can see whats doing wrong, thanks for details. |
In case you're interested, this is where it must be going wrong: https://github.com/spree/deface/blob/master/lib/deface/parser.rb#L53 |
+1. I'm also seeing this problem. |
I'm installing jruby to take a look! |
The problem comes from Nokogiri which apparently parsers / returns different output when run under jruby (as it uses a different java-based parser). |
Thanks for spending the time on this @BDQ . I'll see if it's possible to use the C ext version of Nokogiri on JRuby. |
@benjamintanweihao - would you mind bumping to the latest master and doing some testing, I've made one small change that seems to fix the majority of failures. I still need to change a lot of specs, as nokogiri on jruby doesn't guarantee the order of attributes (like it does on mri), so specs are failing as attrs are coming back in unexpected order. |
I've just tested it, still go no. Here's an example of the error I'm getting: ActionView::Template::Error (/Users/rambo/.rvm/gems/jruby-1.7.1/gems/spree_core-1.1.4/app/views/spree/layouts/spree_application.html.erb:16: syntax error, unexpected tRPAREN ');@output_buffer.safe_concat(' ');@output_buffer.append= ( head) );@output_buffer.safe_concat(' |
What version of Spree are you using? On Thursday 3 January 2013 at 11:53, Benjamin Tan Wei Hao wrote:
|
Spree 1.1.4. |
Do you have a custom override adding that head method? I don't see that in stock 1.1.4? |
You are right. I removed the head, but the problem manifests itself in other places. SyntaxError in Spree/products#show Showing /Users/rambo/.rvm/gems/jruby-1.7.1/gems/spree_core-1.1.4/app/views/spree/products/_image.html.erb where line #2 raised: /Users/rambo/.rvm/gems/jruby-1.7.1/gems/spree_core-1.1.4/app/views/spree/products/_image.html.erb:2: syntax error, unexpected tASSOC Here's the code for _image.html.erb: <% if image %>
<%= image_tag image.attachment.url(:product), :itemprop => "image" %>
<% else %>
<%= product_image(@product, :itemprop => "image") %>
<% end %>
And the error message:
@output_buffer.safe_concat(' ');@output_buffer.append= ( image_tag product), :itemprop => "image" );@output_buffer.safe_concat('
^
Extracted source (around line #2):
1: <% if image %>
2: <%= image_tag product), :itemprop => "image" %>
3: <% else %>
4: <%= link_to(product_image(@product, :itemprop => "image"), "#") %>
5: <% end %>
Trace of template inclusion: /Users/rambo/.rvm/gems/jruby-1.7.1/gems/spree_core-1.1.4/app/views/spree/products/_image.html.erb, /Users/rambo/.rvm/gems/jruby-1.7.1/gems/spree_core-1.1.4/app/views/spree/products/show.html.erb
|
Ok, cool this is something I can work with. I'll report back shortly. |
@benjamintanweihao I'm having trouble replicating this, can you give me the override[s] you're applying to spree/products/_image |
Spree 1.3.2 stock doesn't work on jruby 1.7.2 because of deface. Is this being worked on? |
@swrobel - yes I do intend fixing this, just haven't gotten around to it yet. The problem stems from the fact the Nokogiri uses a completely different parser when running on jruby, and it doesn't behave the same as libxml on MRI. So there's lot of the internals that need to be made aware of the differences. There's a couple of fixes already on master that you could point your Gemfile at, and if you could find an example of the failure (using just core code + a sample override) that would help me a lot? |
It's taken 4 months, but I think I've got jruby working. I've testing both 1.6.2 and 1.7.3 in both 1.8 and 1.9 modes and the specs are passing for me. Anyone still interested can use gem 1.0.0.rc2 to test, and please report back. |
Thank you! Appreciate the hard work. |
Thanks alot @BDQ ! |
@BDQ have you tried running spree on jruby? I still can't get it to work. |
@swrobel, yes it's down to one issue, can you do a gist of the exception you're seeing so I can confirm it's the same as me locally? |
With stock spree 1.3.2 app using sample data https://gist.github.com/swrobel/711843d313918c5e4591 which is essentially the same as what's reported on spree/spree#2748 With my views (I'm not using any deface, but spree still seems to try) I'm essentially getting the same behavior as spree/spree#2633 spree_application.html.erb: https://gist.github.com/swrobel/f95ab76ce605a6486821 LMK if you need more! |
For kicks I tried removing the data-hooks from my layout, but it still closes head & opens body in the same place. |
@swrobel thanks for all the feedback, so you are seeing two issues now:
|
Regarding #2, I don't believe nokogiri for jruby depends on libxml, although I never upgraded so my MRI nokogiri depends on 2.7.8 and I've never seen the issue on it.
|
Ofcourse you're correct libxml will have no effect under Jruby, odd the same issue appears with two separate parsing libraries. |
Is there any progress regarding this issue? |
So I've pushed another fix for this issue and confirmed Spree is working with JRuby + Deface....proof: http://d.pr/i/xlzv I used this branch of spree/spree: https://github.com/spree/spree/tree/jruby and updated the Gemfile to use spree/deface master Anyone else care to test please? |
@BDQ hate to be the bearer of bad news, but I'm still seeing this issue in both my application and stock spree 1-3-stable spree/spree#2633 Try running the html through http://validator.w3.org/ an you'll see it go nuts... |
@swrobel did you use the jruby branch mentioned by @BDQ? |
@parndt no but I looked at the commit and it's really no different than what I already had in my Gemfile. I just updated my Gemfile to use deface/master |
@swrobel spree/spree#2633 is a different issue, this issue was erb tags being escaped incorrectly by jruby, which was causing exceptions preventing any page from rendering. Can you confirm your pages are indeed rendering, and it;s just the head / body tags that are messed up? |
@swrobel - Can you open a new ticket on deface to replicate 2633 for jruby. There's too many issues listed in the comments on this ones. |
I can confirm with both stock spree & my app that views are now rending. This is an improvement from before. Issue for the |
@swrobel great, thanks for that. |
Using jruby-head, deface outputs erb that is missing the leading
<%
or<%=
...This Gist shows the output (pasted from firefox)
Swapping to MRI resolves the problem (confirming it's a jruby thing)
The text was updated successfully, but these errors were encountered: