Slim, only slimmer!
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
bin
lib/slim
spec
.gitignore
.rspec
.rubocop.yml
.travis.yml
Gemfile
README.md
Rakefile
slim-slimmer.gemspec

README.md

Slim::Slimmer

Build Status

Experimental gem to automatically remove unnecessary html tags from your slim output.

As outlined in this styleguide and the HTML5 specification it is safe to omit certain start or end tags from your code.

This gem adds an extra processing step to convert this Slim code:

doctype html
html
  head
    title Example

  body
    p Example

To this html output:

<!DOCTYPE html>
<title>Example</title>
<p>Example

At the moment the gem is very generic and does not implement all the removal rules outlined in the specification (e.g. not removing a tag if it is followed by whitespace or a HTML comment etc.). Hopefully this detail can be added in a future release.

Installation

Add this line to your application's Gemfile:

gem 'slim-slimmer', github: 'neilang/slim-slimmer'

And then execute:

$ bundle

Usage

For best results it is recommended that you change the output format from xhtml to html as this removes the end slash in self-closing tags:

Slim::Engine.options[:format] = :html

You can optionally disable the slimmer feature via this configuration:

Slim::Engine.options[:slimmer] = false