From e170700054800197d97a632e67ec7e52c63fae61 Mon Sep 17 00:00:00 2001
From: Ilia Pozhilov <ilyapoz@gmail.com>
Date: Tue, 29 Mar 2016 17:03:37 +0300
Subject: [PATCH 1/7] Pass raw params to less parser

close #94
---
 lib/less/rails/railtie.rb           | 1 +
 lib/less/rails/template_handlers.rb | 6 +++++-
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/lib/less/rails/railtie.rb b/lib/less/rails/railtie.rb
index 507228d..64b3aa0 100644
--- a/lib/less/rails/railtie.rb
+++ b/lib/less/rails/railtie.rb
@@ -6,6 +6,7 @@ class Railtie < ::Rails::Railtie
       config.less = ActiveSupport::OrderedOptions.new
       config.less.paths = []
       config.less.compress = false
+      config.less.raw = ActiveSupport::OrderedOptions.new
       config.app_generators.stylesheet_engine :less
 
       config.before_initialize do |app|
diff --git a/lib/less/rails/template_handlers.rb b/lib/less/rails/template_handlers.rb
index 6c68580..d1df122 100644
--- a/lib/less/rails/template_handlers.rb
+++ b/lib/less/rails/template_handlers.rb
@@ -26,7 +26,7 @@ def config_to_less_parser_options(scope)
         paths = config_paths(scope) + scope.environment.paths
         local_path = scope.pathname.dirname
         paths += [local_path] unless paths.include? local_path
-        {:filename => eval_file, :line => line, :paths => paths, :dumpLineNumbers => config_from_rails(scope).line_numbers}
+        {:filename => eval_file, :line => line, :paths => paths, :dumpLineNumbers => config_from_rails(scope).line_numbers}.merge(config_raw(scope))
       end
       
       def config_to_css_options(scope)
@@ -36,6 +36,10 @@ def config_to_css_options(scope)
       def config_paths(scope)
         config_from_rails(scope)[:paths]
       end
+
+      def config_raw(scope)
+        config_from_rails(scope)[:raw]
+      end
       
       def config_from_rails(scope)
         scope.environment.context_class.less_config

From f7e44105d1bad562f3cf7518c68f09dee7325c14 Mon Sep 17 00:00:00 2001
From: Ilia Pozhilov <ilyapoz@gmail.com>
Date: Mon, 4 Apr 2016 18:13:45 +0300
Subject: [PATCH 2/7] Update readme and changelog

---
 CHANGELOG.md |  5 +++++
 README.md    | 10 ++++++++++
 2 files changed, 15 insertions(+)

diff --git a/CHANGELOG.md b/CHANGELOG.md
index 2d71158..db7b19d 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,10 @@
 # CHANGELOG
 
+### 2.7.2 - ?
+
+* Make it possible to pass parameters to less.rb
+  Fixes https://github.com/metaskills/less-rails/issues/94
+
 ### 2.7.1 - 2016-09-01
 
 * Fix Sprockets 3 integration. Thanks @suzan2go and @ccallebs!
diff --git a/README.md b/README.md
index 4531295..d94992b 100644
--- a/README.md
+++ b/README.md
@@ -60,6 +60,16 @@ Will end up acting as if you had done this below:
 #leftnav { .border-radius(5px); }
 ```
 
+## Using relative paths for imports
+
+For historical reasons [`less.rb`](https://github.com/cowboyd/less.rb) gem (which `less-rails` is based upon) uses [lessc --relative-urls](http://lesscss.org/usage/#command-line-usage-relative-urls) by default. This means that `url('../ralative/paths.png')` will be modified according to `.less` file location. To return back to default `lessc` behavior, add these lines to `config/initializers/assets.rb`:
+
+```ruby
+Rails.application.config.less.raw.relativeUrls = false
+```
+
+You can pass any parameters that the [less.rb gem](https://github.com/cowboyd/less.rb/blob/master/lib/less/defaults.rb) supports.
+
 
 
 ## Helpers

From 5f5a086129b83b9ff9fa9b5cad1f1368df4d073c Mon Sep 17 00:00:00 2001
From: Ilia Pozhilov <ilyapoz@gmail.com>
Date: Mon, 4 Apr 2016 18:44:04 +0300
Subject: [PATCH 3/7] Invert backwards logic of readme

---
 README.md | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/README.md b/README.md
index d94992b..dc0184d 100644
--- a/README.md
+++ b/README.md
@@ -60,16 +60,16 @@ Will end up acting as if you had done this below:
 #leftnav { .border-radius(5px); }
 ```
 
-## Using relative paths for imports
+## Passing parameters to less.rb
 
-For historical reasons [`less.rb`](https://github.com/cowboyd/less.rb) gem (which `less-rails` is based upon) uses [lessc --relative-urls](http://lesscss.org/usage/#command-line-usage-relative-urls) by default. This means that `url('../ralative/paths.png')` will be modified according to `.less` file location. To return back to default `lessc` behavior, add these lines to `config/initializers/assets.rb`:
+You can pass any parameters that the [`less.rb`](https://github.com/cowboyd/less.rb) gem (which `less-rails` is based upon) supports by modifying `Rails.application.config.less.raw`.
+For example, `less.rb` uses [lessc --relative-urls](http://lesscss.org/usage/#command-line-usage-relative-urls) by default. This means that `url('../ralative/paths.png')` will be modified according to `.less` file location. To return back to default `lessc` behavior, add these lines to `config/initializers/assets.rb`:
 
 ```ruby
 Rails.application.config.less.raw.relativeUrls = false
 ```
 
-You can pass any parameters that the [less.rb gem](https://github.com/cowboyd/less.rb/blob/master/lib/less/defaults.rb) supports.
-
+For more parameters supported by `less.rb`, please consult [less.rb gem](https://github.com/cowboyd/less.rb/blob/master/lib/less/defaults.rb).
 
 
 ## Helpers

From 63acd996459e0eba6886ff4fd90e32c60e5f99a9 Mon Sep 17 00:00:00 2001
From: Ilia Pozhilov <ilyapoz@gmail.com>
Date: Thu, 7 Apr 2016 14:24:05 +0300
Subject: [PATCH 4/7] tests for paremeter passing

---
 test/cases/basics_spec.rb                             | 11 +++++++++++
 test/dummy_app/app/assets/stylesheets/basics.css.less |  2 ++
 .../frameworks/bootstrap/relative_path_url.less       |  3 +++
 3 files changed, 16 insertions(+)
 create mode 100644 test/dummy_app/app/assets/stylesheets/frameworks/bootstrap/relative_path_url.less

diff --git a/test/cases/basics_spec.rb b/test/cases/basics_spec.rb
index e4709a0..11b5c59 100644
--- a/test/cases/basics_spec.rb
+++ b/test/cases/basics_spec.rb
@@ -45,6 +45,17 @@ class BasicsSpec < Less::Rails::Spec
 
   end
 
+  describe 'relative path setting must be effective' do
+    it 'must use relavite paths by default' do
+      basics.must_match %r{body\{background-image:url\('i-have-no-imagination.png'\)\}}
+    end
+
+    it 'should respond to config modification' do
+      Rails.application.config.less.raw.relativeUrls = false;
+      basics.must_match %r{body\{background-image:url\('../../i-have-no-imagination.png'\)\}}
+    end
+  end
+
   protected
   
   def basics
diff --git a/test/dummy_app/app/assets/stylesheets/basics.css.less b/test/dummy_app/app/assets/stylesheets/basics.css.less
index 2cfe8f6..90e64dc 100644
--- a/test/dummy_app/app/assets/stylesheets/basics.css.less
+++ b/test/dummy_app/app/assets/stylesheets/basics.css.less
@@ -16,3 +16,5 @@
 // Vendored
 @import "vendored";
 #test-vendored { .vendored; }
+
+@import "frameworks/bootstrap/relative_path_url";
diff --git a/test/dummy_app/app/assets/stylesheets/frameworks/bootstrap/relative_path_url.less b/test/dummy_app/app/assets/stylesheets/frameworks/bootstrap/relative_path_url.less
new file mode 100644
index 0000000..a05469f
--- /dev/null
+++ b/test/dummy_app/app/assets/stylesheets/frameworks/bootstrap/relative_path_url.less
@@ -0,0 +1,3 @@
+body {
+    background-image: url('../../i-have-no-imagination.png');
+}

From 0e8cbea702fa3ce4026cd0ef8a35a148099cc9a4 Mon Sep 17 00:00:00 2001
From: Ilia Pozhilov <ilyapoz@users.noreply.github.com>
Date: Thu, 7 Apr 2016 14:28:34 +0300
Subject: [PATCH 5/7] Update README.md

---
 README.md | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/README.md b/README.md
index dc0184d..c8b0e8c 100644
--- a/README.md
+++ b/README.md
@@ -63,7 +63,7 @@ Will end up acting as if you had done this below:
 ## Passing parameters to less.rb
 
 You can pass any parameters that the [`less.rb`](https://github.com/cowboyd/less.rb) gem (which `less-rails` is based upon) supports by modifying `Rails.application.config.less.raw`.
-For example, `less.rb` uses [lessc --relative-urls](http://lesscss.org/usage/#command-line-usage-relative-urls) by default. This means that `url('../ralative/paths.png')` will be modified according to `.less` file location. To return back to default `lessc` behavior, add these lines to `config/initializers/assets.rb`:
+For example, `less.rb` uses [lessc --relative-urls](http://lesscss.org/usage/#command-line-usage-relative-urls) by default. This means that `url('../ralative/paths.png')` for `@import`ed files will be modified according to `.less` file location. To return back to default `lessc` behavior, add these lines to `config/initializers/assets.rb`:
 
 ```ruby
 Rails.application.config.less.raw.relativeUrls = false

From f5e5eb255424abeab8363b62fef24ba0fc097373 Mon Sep 17 00:00:00 2001
From: Ilia Pozhilov <ilyapoz@gmail.com>
Date: Thu, 7 Apr 2016 21:23:18 +0300
Subject: [PATCH 6/7] try configuring explicitly

---
 test/cases/basics_spec.rb | 1 +
 1 file changed, 1 insertion(+)

diff --git a/test/cases/basics_spec.rb b/test/cases/basics_spec.rb
index 11b5c59..6db6dad 100644
--- a/test/cases/basics_spec.rb
+++ b/test/cases/basics_spec.rb
@@ -47,6 +47,7 @@ class BasicsSpec < Less::Rails::Spec
 
   describe 'relative path setting must be effective' do
     it 'must use relavite paths by default' do
+      Rails.application.config.less.raw.relativeUrls = true;
       basics.must_match %r{body\{background-image:url\('i-have-no-imagination.png'\)\}}
     end
 

From d2201c2091747f697adc501f03c584677812def0 Mon Sep 17 00:00:00 2001
From: Ilia Pozhilov <ilyapoz@gmail.com>
Date: Thu, 7 Apr 2016 22:52:25 +0300
Subject: [PATCH 7/7] parameters cleanup after tests

---
 test/cases/basics_spec.rb | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/test/cases/basics_spec.rb b/test/cases/basics_spec.rb
index 6db6dad..698a0a2 100644
--- a/test/cases/basics_spec.rb
+++ b/test/cases/basics_spec.rb
@@ -46,13 +46,16 @@ class BasicsSpec < Less::Rails::Spec
   end
 
   describe 'relative path setting must be effective' do
+    after do
+      Rails.application.config.less.raw.clear
+    end
+
     it 'must use relavite paths by default' do
-      Rails.application.config.less.raw.relativeUrls = true;
       basics.must_match %r{body\{background-image:url\('i-have-no-imagination.png'\)\}}
     end
 
     it 'should respond to config modification' do
-      Rails.application.config.less.raw.relativeUrls = false;
+      Rails.application.config.less.raw.relativeUrls = false
       basics.must_match %r{body\{background-image:url\('../../i-have-no-imagination.png'\)\}}
     end
   end