Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Hi,
I strongly suggest that you add a Gemfile to Zen, specifying the gems needed to work with Sass. The following Gemfile would probably do the job:
source "http://rubygems.org/"
gem "sass"
gem "compass"
gem "zen-grids"
With this and Bundler, getting started with Sass is just a matter of
cd path/to/my/zen/sub-theme
bundle install --path .bundle
bundle install --binstubs
This would make a sub-theme project self-contained. Using Bundler is standard practice for managing dependencies in Ruby projects. Among the rest, it avoids the problems like the one mentioned at http://drupal.org/node/1548946#comment-6070036. Besides, no root privileges are needed (the commands are not run with sudo), and you can get rid of the sass-extensions folder.
Comments
Comment #1
lifepillar CreditAttribution: lifepillar commentedTo be precise, you might remove
extensions_dir="sass-extensions"
and addrequire 'zen-grids'
instead, in config.rb.Comment #2
JohnAlbinA sub-theme isn't a Ruby project. It's a PHP project.
Can you explain in more detail what advantages this would give us? And how to implement it?
Comment #3
lifepillar CreditAttribution: lifepillar commentedIt's PHP, but to use Sass you need to install some Ruby gems. Typically, a user may install gems globally with “sudo gem install ”, but installing gems globally has some disadvantages because, in general, root privileges are needed and conflicts may arise (as witnessed by the comment I have linked to). In the Ruby community, it has become customary to include, in every project that depends on Ruby gems (not necessarily a Ruby project), a text file called “Gemfile”, which is a specification of gem dependencies for the project. Giving a single command like “bundle install”, a user may have all the gem dependencies installed in a subfolder of the project (think of it as “drush make” for gems). Advantages:
To implement my suggestion, you just need to add a Gemfile in the top folder of the Zen sub-theme. If you include zen-grids in the Gemfile, you may also remove the sass-extensions folder and uncomment “require zen-grids" in config.rb instead, as I have explained. A user not interested in Sass or not using Bundler may simply ignore the Gemfile or delete it.
For the details about Bundler and Gemfiles, see http://gembundler.com.
Comment #4
JohnAlbinThat's interesting. But it seems to be duplicate functionality with 'compass unpack' which will “Copy an extension into your extensions folder”.
I have not seen anybody in the Compass community talking about using Bundler. But I have seen them many times talking about adding "require" to the compass.config file.
I think I'd rather use a standard Compass feature over a standard Ruby feature. Especially since you can use Zen's config.rb and Zen Grids with GUI-only tools with Compass built-in, like Fire.app. http://fireapp.handlino.com
Comment #5
lifepillar CreditAttribution: lifepillar commentedYes, compass unpack has overlapping features, but the two (Compass and Bundler) may live together. You may “compass unpack zen-grids”, but you still may use “bundle install” to get Sass and Compass (and possibly other gems in the future) in the first place. The advantage is mainly in keeping those gems up to date: “bundle update” does not affect anything outside the sub-theme folder. Without Bundler, users would likely use “(sudo) gem update”, which updates all the gems in the system, with the risk of breaking other Ruby apps.
But I understand your point and I won't insist any further: after all, adding a Gemfile manually to a sub-theme, as I have done for mine, is not too much of a burden. Maybe, this approach might be just documented.
Comment #6
JohnAlbinThanks for the information.
I don't like to add stuff to Zen that I don't understand. Especially since everything needs to be well documented. I think adding it at this point would just be confusing to users not familiar with Bundler (like me.)
Comment #7
JohnAlbinReopening!
Comment #8
MacMladen CreditAttribution: MacMladen commentedI'd just add that there are two kinds of people:
If we are looking at those who are not familiar with Ruby, Gems and overall process then we will see that they will hardly be able make proper use of SASS while usage of SASS, Compass, Ruby, Gems, RVM, Bundler is not too complicated for skilled developers which are targeted by Zen.
Adding Gemfile will be in line with good practice, does not add any complexity and helps maintain dependencies and mental health. It could be very tricky in some situations even for skilled ones.
If you agree I can add something like [#1936970] for Zen theme in documentation? There are some obstacles and some terminology that need explanation and I'd be glad to document it. (I will do so in some time unless you oppose and sooner if there is interest)
Comment #9
JohnAlbinI've added this to both 7.x-5.x and 7.x-6.x.
Comment #10
JohnAlbinI've updated the README file included with Zen, but this still needs online docs.
@MacMladen I'd love some help! Thanks for the offer.
Comment #12
JohnAlbinMoved docs updates to a new issue