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

Sass improvements #1365

Merged
merged 2 commits into from Oct 14, 2018

Conversation

Projects
None yet
2 participants
@gpakosz
Member

gpakosz commented Oct 6, 2018

This PR has come a long way. I started it in January 2018.

I've never been a fan of monkey patching the Sass Filesystem importer implementation to achieve proper dependency tracking. So I started looking at Sass Ruby code (before they deprecate it but that's another story)...

Detailed description

I started replacing the monkey patching by a proper custom importer.
From there, I thought it would be cool to import Sass partials by identifier, with the wildcard syntax of modern identifiers.

Then I added support for source maps, with an additional :sass_sourcemap filter.

And finally, I added a nanoc() Sass function that lets Sass code snoop into Nanoc's @config or @items by evaluating a string within the filter's context.

To do

  • Tests
  • Documentation (I believe nanoc.ws should be updated)

gpakosz added some commits Oct 6, 2018

Implemented new :sass and :sass_sourcemap filters
This commit introduces a Nanoc aware Sass importer that:
  - does not rely on monkey patching Sass Filesystem importer implementation
  - reasons about items instead of file which means:
    - you can import by identifier
    - you can import by pattern
    - you can import in memory and/or filtered items
Added nanoc() sass custom function
Example usage, from within sass code:

@if nanoc('@config.dig(:items, :headings, :auto_number)') {
   body { counter-reset: h2; }
   h2 { counter-reset: h3; }
   h3 { counter-reset: h4; }
   h4 { counter-reset: h5; }
   h5 { counter-reset: h6; }

   h2:before { counter-increment: h2; content: counter(h2) ". "; }
   h3:before { counter-increment: h3; content: counter(h2) "." counter(h3) ". "; }
   h4:before { counter-increment: h4; content: counter(h2) "." counter(h3) "." counter(h4) ". "; }
   h5:before { counter-increment: h5; content: counter(h2) "." counter(h3) "." counter(h4) "." counter(h5) ". "; }
   h6:before { counter-increment: h6; content: counter(h2) "." counter(h3) "." counter(h4) "." counter(h5) "." counter(h6) ". "; }

   h2.nocount:before, h3.nocount:before, h4.nocount:before, h5.nocount:before, h6.nocount:before { content: ""; counter-increment: none; }
}

Or even,

.title {
  color: nanoc('@config[:title][:color]', $unquote: true)
}

@ddfreyne ddfreyne changed the base branch from master to trunk Oct 10, 2018

@ddfreyne ddfreyne changed the base branch from trunk to master Oct 13, 2018

@gpakosz gpakosz referenced this pull request Oct 13, 2018

Merged

Document new Sass features #223

@ddfreyne ddfreyne merged commit dc459c5 into nanoc:master Oct 14, 2018

3 checks passed

codecov/patch Coverage not affected when comparing f10141d...dbd6af6
Details
codecov/project 98.42% (-0.04%) compared to f10141d
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment