Skip to content
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
Merged

Sass improvements #1365

merged 2 commits into from Oct 14, 2018

Conversation

gpakosz
Copy link
Member

@gpakosz 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)

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
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)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants