google-code-export / wro4j

Automatically exported from code.google.com/p/wro4j
1 stars 1 forks source link

Add Path awareness to RubySassEngine #888

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
As stated on https://code.google.com/p/wro4j/wiki/RubySassCss you mention that 
Ruby doesnt know how to set the path to your local @import's. This can be 
resolved by setting the load_path options in the sass engine object.

I attached the modified RubySassCss.java file renamed to 
PathAwareRubySassEngine. You use it by doing:

PathAwareRubySassEngine engine = new PathAwareRubySassEngine();
engine.addLoadPath("some/path/to/more_resources");
engine.process(...);

This allows the @imports to be actually located.

  require 'rubygems'                                   
  require 'sass/plugin'                                   
  require 'sass/engine'                                   
engine = Sass::Engine.new("@import 'modules/button/style.scss';

$font-stack:    Helvetica, sans-serif;

body {
  font: 100% $font-stack;
  color: $primary-color;
}", {:syntax => :scss})
engine.options[:load_paths].tap do |load_paths|
  load_paths << Sass::Importers::Filesystem.new('c:/workdir/csstheme/resource')
end
result = engine.render

Original issue reported on code.google.com by nstu...@earthadvantage.org on 2 Aug 2014 at 3:45

Attachments:

GoogleCodeExporter commented 9 years ago
Thanks,

I will add this in one of the future releases.

Original comment by alex.obj...@gmail.com on 5 Aug 2014 at 3:12

GoogleCodeExporter commented 9 years ago
Do you see it a replacement of current RubySassEngine implementation or it 
should coexist with the old one?

Original comment by alex.obj...@gmail.com on 5 Aug 2014 at 3:18

GoogleCodeExporter commented 9 years ago
I would think it would be integrated with the existing RubySassEngine. The 
changes don't affect any existing integration so users wont have any problems 
when upgrading to a newer version. 

However I am not familiar with this libraries configuration setup but if you 
end up reworking how the load paths are set (possible XML config) it may end up 
needing its own separate class.

Original comment by nstu...@earthadvantage.org on 5 Aug 2014 at 3:39

GoogleCodeExporter commented 9 years ago
I should also mention that at line 122 reads:
loadPath.replaceAll("'", "\\'").replaceAll("\\\\", "/")

That line should be looked at, I dont know Ruby very well and am not sure how 
their path separators work but the replaceAll("\\\\", "/") has red flags all 
over it. I couldnt seem to get the path to go into Ruby nicely but im sure 
theres a proper way to do this. Definitely something to fix before you put it 
in a release.

Original comment by nstu...@earthadvantage.org on 5 Aug 2014 at 3:45

GoogleCodeExporter commented 9 years ago

Original comment by alex.obj...@gmail.com on 25 Sep 2014 at 8:25