slim-embedded-minify 0.2.7 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 559dbaf2124f8ff4c7e5c7a41f6420ad9bd16c6ee008e3d54af3d5263ddc7509
4
- data.tar.gz: 7a9612c610b3f4bb61a8712b3c875aca6d752e5710a55a88cfe41a3e18594322
3
+ metadata.gz: edfcf0b035a028347851a0da709399cb3bec750fe7f2ff1079c8bb8820734a96
4
+ data.tar.gz: 010cce6d6b7967d5bc4e71cb07825bfa0a7feedcaa2aab51c0e7c53345bb6b88
5
5
  SHA512:
6
- metadata.gz: c3a31cce0082ecd69d49bcaffde0b9e6e992c5b178e0a6678071dfb7b3ab7196078b86d297b67680cadd4faac561fe31770b7df25dac40427c38f3f97aad787f
7
- data.tar.gz: a6003c38359fe0f33c309554bd3d3dfa3afd527d9b1aeb42f8290074dc0488dcbd5894a5ac7a02923b422fb2168e98e6abcd02d1c437101f5e56ea4f4da7e4b0
6
+ metadata.gz: 5183dcbcf55c05929d668e465aa773731f3fdccc1951eca4d400e92c9dd936edcd61dca49a90d6d168236375547fab03fbd249210409d8480b6d1b3ba3934984
7
+ data.tar.gz: 5ad28ded0fd0e5060689ad52ba40fef264766c3b65bba93a8564829e4fc0edb10c3d3c5d94d9ed99b980836f5a22c3c312ba4b578d0e238cf0d909748fa44bb5
data/.yardopts ADDED
@@ -0,0 +1,2 @@
1
+ --markup markdown
2
+ --hide-void-return
data/CHANGELOG.md CHANGED
@@ -1,5 +1,12 @@
1
1
  ## Unreleased
2
2
 
3
+ ## 1.0.0 - 2026-01-24
4
+
5
+ - Support for SCSS embedded engine minification
6
+ - Support for Sass embedded engine minification
7
+ - Support for Less embedded engine minification
8
+ - Support for CoffeeScript embedded engine minification
9
+
3
10
  ## 0.2.7 - 2023-08-01
4
11
 
5
12
  - Fix incorrect removing when using escaped quotation for css.
data/Gemfile CHANGED
@@ -7,3 +7,4 @@ gemspec
7
7
 
8
8
  gem "minitest", "~> 5.15"
9
9
  gem "rake", "~> 13.0"
10
+ gem "yard"
data/README.md CHANGED
@@ -1,23 +1,133 @@
1
1
  # SlimEmbeddedMinify
2
2
 
3
3
  [![Gem Version](https://badge.fury.io/rb/slim-embedded-minify.svg)](https://badge.fury.io/rb/slim-embedded-minify)
4
+ [![test](https://github.com/ydah/slim-embedded-minify/actions/workflows/minitest.yml/badge.svg)](https://github.com/ydah/slim-embedded-minify/actions/workflows/minitest.yml)
5
+ [![RubyDoc](https://img.shields.io/badge/%F0%9F%93%9ARubyDoc-documentation-informational.svg)](https://www.rubydoc.info/gems/slim-embedded-minify)
4
6
 
5
7
  A slim file to minify embedded code.
6
8
 
7
- ## Installation
9
+ ## Overview
10
+
11
+ Remove comments and unnecessary blank lines in the [css or javascript embedding](https://github.com/slim-template/slim#embedded-engines-markdown-) of your Slim files when embedding them in HTML.
12
+
13
+ ### Example
14
+
15
+ You have a Slim file like this:
8
16
 
9
- Just install the slim-embedded-minify gem
17
+ ```slim
18
+ html
19
+ head
20
+ title My Slim Template
21
+ body
22
+ h1 Welcome to Slim!
23
+ css:
24
+ /* Slim supports embedded css */
10
25
 
26
+
27
+ body { background-color: #ddd; }
28
+ javascript:
29
+ // Slim supports embedded javascript
30
+ alert('Slim supports embedded javascript!')
11
31
  ```
12
- gem install slim-embedded-minify
32
+
33
+ If this gem is not applied, the HTML will look like the following:
34
+
35
+ ```html
36
+ <html>
37
+ <head>
38
+ <title>My Slim Template</title>
39
+ </head>
40
+ <body>
41
+ <h1>
42
+ Welcome to Slim!
43
+ </h1>
44
+ <style>
45
+ /* Slim supports embedded css */
46
+
47
+
48
+ body { background-color: #ddd; }
49
+ </style>
50
+ <script>
51
+ // Slim supports embedded javascript
52
+ alert('Slim supports embedded javascript!')
53
+ </script>
54
+ </body>
55
+ </html>
13
56
  ```
14
57
 
15
- or if you use bundler put this in your `Gemfile`
58
+ Applying this gem will remove unnecessary blank lines and comments:
16
59
 
60
+ ```html
61
+ <html>
62
+ <head>
63
+ <title>My Slim Template</title>
64
+ </head>
65
+ <body>
66
+ <h1>
67
+ Welcome to Slim!
68
+ </h1>
69
+ <style>
70
+ body { background-color: #ddd; }
71
+ </style>
72
+ <script>
73
+ alert('Slim supports embedded javascript!')
74
+ </script>
75
+ </body>
76
+ </html>
17
77
  ```
78
+
79
+ ## Installation
80
+
81
+ Add this line to your application's Gemfile:
82
+
83
+ ```ruby
84
+ # Gemfile
85
+ gem 'slim'
18
86
  gem 'slim-embedded-minify'
19
87
  ```
20
88
 
89
+ And then execute:
90
+
91
+ ```
92
+ bundle install
93
+ ```
94
+
95
+ ## Usage
96
+
97
+ All you have to do is add this gem to your Gemfile.
98
+ No additional configuration or changes to your code are required.
99
+
100
+ ```ruby
101
+ # Gemfile
102
+ gem 'slim'
103
+ gem 'slim-embedded-minify'
104
+ ```
105
+
106
+ ## Supported Embedded Engines
107
+
108
+ This gem supports minification for the following Slim embedded engines:
109
+
110
+ | Engine | Comment Removal | Blank Line Removal |
111
+ |--------|----------------|-------------------|
112
+ | `css:` | `/* */` | ✓ |
113
+ | `javascript:` | `//`, `/* */` | ✓ |
114
+ | `scss:` | `/* */` (after compilation) | ✓ |
115
+ | `sass:` | `/* */` (after compilation) | ✓ |
116
+ | `less:` | `/* */` (after compilation) | ✓ |
117
+ | `coffee:` | `//`, `/* */` (after compilation) | ✓ |
118
+
119
+ ### Note on Compile-time Engines
120
+
121
+ For `scss:`, `sass:`, `less:`, and `coffee:` engines, the minification is applied
122
+ to the compiled output (CSS or JavaScript), not the source code. This means:
123
+
124
+ - SCSS/Sass/Less single-line comments (`//`) are already removed during compilation
125
+ - Only CSS-style comments (`/* */`) remain and are removed by this gem
126
+ - CoffeeScript comments become JavaScript comments after compilation and are then removed
127
+
128
+ These engines require their respective compiler gems to be installed; if a compiler is
129
+ missing, Slim will raise an error when compiling the embedded code.
130
+
21
131
  ## Contributing
22
132
 
23
133
  Bug reports and pull requests are welcome on GitHub at https://github.com/ydah/slim-embedded-minify. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/ydah/slim-embedded-minify/blob/main/CODE_OF_CONDUCT.md).
@@ -3,6 +3,7 @@
3
3
  module Slim
4
4
  class Embedded < Filter
5
5
  module Minify
6
+ # Minify embedded Javascript code in Slim templates.
6
7
  module Javascript
7
8
  include Tag
8
9
 
@@ -11,6 +12,8 @@ module Slim
11
12
  super(engine, minified_body, attrs)
12
13
  end
13
14
 
15
+ private
16
+
14
17
  def remove_comments!(line)
15
18
  need_deletion = false
16
19
  need_deletion_all = false
@@ -3,9 +3,12 @@
3
3
  module Slim
4
4
  class Embedded < Filter
5
5
  module Minify
6
+ # Minify embedded tag code in Slim templates.
6
7
  module Tag
8
+ CSS_ENGINES = %i[css sass scss less].freeze
9
+
7
10
  def on_slim_embedded(engine, body, attrs)
8
- body = minify(body) if engine == :css
11
+ body = minify(body) if CSS_ENGINES.include?(engine)
9
12
  super(engine, body, attrs)
10
13
  end
11
14
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module SlimEmbeddedMinify
4
- VERSION = "0.2.7"
4
+ VERSION = "1.0.0"
5
5
  end
@@ -16,5 +16,9 @@ module Slim
16
16
  class JavaScriptEngine < TagEngine
17
17
  prepend Minify::Javascript
18
18
  end
19
+
20
+ class SassEngine
21
+ prepend Minify::Tag
22
+ end
19
23
  end
20
24
  end
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: slim-embedded-minify
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.7
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yudai Takada
8
- autorequire:
9
8
  bindir: exe
10
9
  cert_chain: []
11
- date: 2023-08-01 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
13
  name: slim
@@ -24,13 +23,13 @@ dependencies:
24
23
  - - "~>"
25
24
  - !ruby/object:Gem::Version
26
25
  version: '5.1'
27
- description:
28
26
  email:
29
27
  - t.yudai92@gmail.com
30
28
  executables: []
31
29
  extensions: []
32
30
  extra_rdoc_files: []
33
31
  files:
32
+ - ".yardopts"
34
33
  - CHANGELOG.md
35
34
  - CODE_OF_CONDUCT.md
36
35
  - Gemfile
@@ -50,7 +49,6 @@ metadata:
50
49
  source_code_uri: https://github.com/ydah/slim-embedded-minify
51
50
  changelog_uri: https://github.com/ydah/slim-embedded-minify/releases
52
51
  rubygems_mfa_required: 'true'
53
- post_install_message:
54
52
  rdoc_options: []
55
53
  require_paths:
56
54
  - lib
@@ -65,8 +63,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
65
63
  - !ruby/object:Gem::Version
66
64
  version: '0'
67
65
  requirements: []
68
- rubygems_version: 3.4.10
69
- signing_key:
66
+ rubygems_version: 4.0.4
70
67
  specification_version: 4
71
68
  summary: A slim file to minify embedded code.
72
69
  test_files: []