Skip to content

ydah/slim-embedded-minify

Repository files navigation

SlimEmbeddedMinify

Gem Version

A slim file to minify embedded code.

Overview

Remove comments and unnecessary blank lines in the css or javascript embedding of your Slim files when embedding them in HTML.

Example

You have a Slim file like this:

html
  head
    title My Slim Template
  body
    h1 Welcome to Slim!
    css:
      /* Slim supports embedded css */


      body { background-color: #ddd; }
    javascript:
      // Slim supports embedded javascript
      alert('Slim supports embedded javascript!')

If this gem is not applied, the HTML will look like the following:

<html>
  <head>
    <title>My Slim Template</title>
  </head>
  <body>
    <h1>
      Welcome to Slim!
    </h1>
    <style>
      /* Slim supports embedded css */


      body { background-color: #ddd; }
    </style>
    <script>
      // Slim supports embedded javascript
      alert('Slim supports embedded javascript!')
    </script>
  </body>
</html>

Applying this gem will remove unnecessary blank lines and comments:

<html>
  <head>
    <title>My Slim Template</title>
  </head>
  <body>
    <h1>
      Welcome to Slim!
    </h1>
    <style>
      body { background-color: #ddd; }
    </style>
    <script>
      alert('Slim supports embedded javascript!')
    </script>
  </body>
</html>

Installation

Add this line to your application's Gemfile:

# Gemfile
gem 'slim'
gem 'slim-embedded-minify'

And then execute:

bundle install

Usage

All you have to do is add this gem to your Gemfile. No additional configuration or changes to your code are required.

# Gemfile
gem 'slim'
gem 'slim-embedded-minify'

Contributing

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.

License

The gem is available as open source under the terms of the MIT License.

Code of Conduct

Everyone interacting in the Slim::Embedded::Minify project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.