nanoc-dart-sass 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/NEWS.md +5 -0
- data/README.md +31 -0
- data/lib/nanoc/dart-sass.rb +3 -0
- data/lib/nanoc/dart_sass/filter.rb +60 -0
- data/lib/nanoc/dart_sass/version.rb +7 -0
- data/lib/nanoc/dart_sass.rb +11 -0
- data/lib/nanoc-dart-sass.rb +3 -0
- metadata +78 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 40b93740b864b61bac9b890e3076e2f52ed675d85ec815296d22a29e3d3bb1cf
|
4
|
+
data.tar.gz: ccfc074b2ac62ed6172ead70e9f3c77311633885efaec81cf1b371bf45d68b51
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 665aabe49726e3ec886549f46331d343df41341568fadbc6cd1a4273601e32e41ae1b7d03a48a973ab08745a4ae2b8929b328ef2f4196827580ab92a04a9aecc
|
7
|
+
data.tar.gz: c0d0dcf3bf0ea5978886b544982e57bed7ff06649dd64e14367299f616d4915bdbd164b8a8f1b4f72bafffe5c5caebee9175656758fdfa4246998f8529a2bc69
|
data/NEWS.md
ADDED
data/README.md
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
# nanoc-dart-sass
|
2
|
+
|
3
|
+
This provides a filter that allows [Nanoc](https://nanoc.app) to process content via [Dart Sass](https://sass-lang.com/dart-sass).
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add `nanoc-dart-sass` to the `nanoc` group of your Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
group :nanoc do
|
11
|
+
gem 'nanoc-dart-sass'
|
12
|
+
end
|
13
|
+
```
|
14
|
+
|
15
|
+
## Usage
|
16
|
+
|
17
|
+
Call the `:dart_sass` filter. For example:
|
18
|
+
|
19
|
+
```ruby
|
20
|
+
filter :dart_sass
|
21
|
+
```
|
22
|
+
|
23
|
+
Options passed to this filter will be passed on to Dart Sass. For example:
|
24
|
+
|
25
|
+
```ruby
|
26
|
+
filter :dart_sass, syntax: 'scss'
|
27
|
+
```
|
28
|
+
|
29
|
+
```ruby
|
30
|
+
filter :dart_sass, syntax: 'scss'
|
31
|
+
```
|
@@ -0,0 +1,60 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Nanoc
|
4
|
+
module DartSass
|
5
|
+
class Filter < Nanoc::Filter
|
6
|
+
identifier :dart_sass
|
7
|
+
|
8
|
+
# Runs the content through [Dart Sass](https://sass-lang.com/dart-sass).
|
9
|
+
# Parameters passed as `:args` will be passed on to Dart Sass.
|
10
|
+
#
|
11
|
+
# @param [String] content The content to filter
|
12
|
+
#
|
13
|
+
# @return [String] The filtered content
|
14
|
+
def run(content, params = {})
|
15
|
+
# Read syntax
|
16
|
+
syntax = params[:syntax]
|
17
|
+
syntax ||=
|
18
|
+
case item.identifier.ext
|
19
|
+
when 'sass'
|
20
|
+
:indented
|
21
|
+
when 'scss'
|
22
|
+
:scss
|
23
|
+
when 'css'
|
24
|
+
:css
|
25
|
+
else
|
26
|
+
nil
|
27
|
+
end
|
28
|
+
|
29
|
+
result = Sass.compile_string(
|
30
|
+
content,
|
31
|
+
importer: make_dart_sass_importer(@items),
|
32
|
+
**params,
|
33
|
+
syntax: syntax,
|
34
|
+
)
|
35
|
+
result.css
|
36
|
+
rescue StandardError => e
|
37
|
+
# TODO: use full_message for syntax errors
|
38
|
+
raise e
|
39
|
+
end
|
40
|
+
|
41
|
+
private
|
42
|
+
|
43
|
+
def make_dart_sass_importer(items)
|
44
|
+
{
|
45
|
+
canonicalize: lambda do |param, **|
|
46
|
+
"nanoc:#{items[param.sub(/\Ananoc:/, '')].identifier}"
|
47
|
+
end,
|
48
|
+
load: lambda { |url|
|
49
|
+
param = url.sub(/\Ananoc:/, '')
|
50
|
+
item = items[param]
|
51
|
+
return {
|
52
|
+
contents: item.raw_content,
|
53
|
+
syntax: item.identifier.ext,
|
54
|
+
}
|
55
|
+
},
|
56
|
+
}
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
metadata
ADDED
@@ -0,0 +1,78 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: nanoc-dart-sass
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Denis Defreyne
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2022-11-20 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: nanoc-core
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '4.12'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '4.12'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: sass-embedded
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.56'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.56'
|
41
|
+
description: Provides a :dart_sass filter for Nanoc
|
42
|
+
email: denis+rubygems@denis.ws
|
43
|
+
executables: []
|
44
|
+
extensions: []
|
45
|
+
extra_rdoc_files: []
|
46
|
+
files:
|
47
|
+
- NEWS.md
|
48
|
+
- README.md
|
49
|
+
- lib/nanoc-dart-sass.rb
|
50
|
+
- lib/nanoc/dart-sass.rb
|
51
|
+
- lib/nanoc/dart_sass.rb
|
52
|
+
- lib/nanoc/dart_sass/filter.rb
|
53
|
+
- lib/nanoc/dart_sass/version.rb
|
54
|
+
homepage: https://nanoc.ws/
|
55
|
+
licenses:
|
56
|
+
- MIT
|
57
|
+
metadata:
|
58
|
+
rubygems_mfa_required: 'true'
|
59
|
+
post_install_message:
|
60
|
+
rdoc_options: []
|
61
|
+
require_paths:
|
62
|
+
- lib
|
63
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
64
|
+
requirements:
|
65
|
+
- - ">="
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
version: '2.7'
|
68
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
69
|
+
requirements:
|
70
|
+
- - ">="
|
71
|
+
- !ruby/object:Gem::Version
|
72
|
+
version: '0'
|
73
|
+
requirements: []
|
74
|
+
rubygems_version: 3.3.26
|
75
|
+
signing_key:
|
76
|
+
specification_version: 4
|
77
|
+
summary: Dart Sass filter for Nanoc
|
78
|
+
test_files: []
|