Added custom Less Template with support for tracking @import-ed files #323

Closed
wants to merge 4 commits into
from

Conversation

Projects
None yet
5 participants

@josh wdyt?

This is based in the implementation done in less-rails but I've found this useful in non-rails apps.

I'm not sure about tests since less depends on therubyracer/therubyrhino and you removed it from Gemfile

Contributor

josh commented Apr 26, 2012

Parsing @import with a regexp is sketch.

It'd be nice of the ::Less::Parser.new returned an array of "dependencies" files. It knows of course.

something like

module Less
  class Tree
    def dependencies
      Less::JavaScript.exec { @tree.rules.map{|x| x[:path]  } }.compact
      # => ["mixin1.less", "mixin2.less"]
    end
  end
end

right?

Sorry, I was wrong, it should be:

module Less
  class Parser
    def imports
      Less::JavaScript.exec { @parser.imports }.files.map{|file, content| file}
      # => ["mixin1.less", "mixin2.less"]
    end
  end
end
Contributor

josh commented Apr 27, 2012

That'd be nice. I think they should add that to the ruby less api first.

@josh done in https://github.com/cowboyd/less.rb/blob/master/lib/less/parser.rb#L41-43, but I guess we should wait for a new release of less gem, right?

Contributor

josh commented May 10, 2012

Cool, can you update the patch. Just want to make sure all this is going to be a stable api going forward.

This pull request passes (merged 72b8d93 into b777136).

This pull request passes (merged e6ba2f4 into b777136).

Contributor

josh commented Oct 10, 2012

Did this api ever get standardized?

@josh yes, a new version of less.rb was released some time ago and it includes the API

Contributor

josh commented Oct 17, 2012

Great. I might need some time to review and test, but I definitely want to get this in core.

SaitoWu commented May 4, 2013

+1

Contributor

josh commented Feb 9, 2014

Hmm, I'd like this in core, but its seems like less is kinda not very popular since sass is already pure ruby. I might just drop it from core and let plugin authors add support. Thanks for writing this up though.

@josh josh closed this Feb 9, 2014

👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment