Skip to content

A gem that adds slim-lang support to Jekyll.

License

Notifications You must be signed in to change notification settings

aiomaster/jekyll-slim

 
 

Repository files navigation

Jekyll-slim

Gem Version Dependency Status Code Climate Build Status

A gem that adds slim-lang support to Jekyll. Works for for pages, includes and layouts.

Installation

Add this line to your Gemfile in the group "jekyll-plugins":

gem 'jekyll-slim', git: 'https://github.com/aiomaster/jekyll-slim'

And then execute:

$ bundle

Or install it yourself as:

$ gem install jekyll-slim

In your Jekyll project's _config.yml:

# _config.yml
plugins:
 - jekyll-slim

Usage

The gem will convert all the .slim files in your project's directory into HTML. That includes files in sub-directories, includes and layouts. Example:

# _layouts/default.slim
html
  head
  body
    .content-wrapper {{ content }}

To include a partial, use include_template and set the local variables you like:

# index.slim
---
layout: default
---

section.content Content goes here.
== include_template 'footer.slim', foo: 'cool shit', bar: 'another cool shit'

You can access these local variables with the include key.

# footer.slim
h1 = include.foo
p = include.bar

That way your footer.slim can also be included from any other template via liquid:

<div class="footer">
{%- include footer.slim foo="yeah" bar="cool" -%}
</div>

You can access your site data like you would do in liquid: For example if you have

# _data/topics.yml
- title: Cool slim
  description: slim is fantastic
- title: Fancy slim
  description: I like slim

and in your template

- site.data.topics.each do |topic|
  h2 = topic.title
  p = topic.description

How cool is that? Can you feel the power of slim and ruby? But what about all these fancy liquid filters we need sometimes? No problem:

p id="#{render_liquid('tittle | slugify', title: 'slug i fy me')}"

Just give the liquid expression as a string and every variable you would like to access in a hash.

Options

Is possible to set options available for Slim engine through the slim key in _config.yml. Example:

# _config.yml
slim:
  pretty: true
  format: html5

Credit

Jekyll-slim was heavily inspired by jekyll-haml. It is free software, and may be redistributed under the terms specified in the LICENSE file.

I found this gem jekyll-slim, but it is archived, so I made my own fork from someone who removed the sliq experiments from it. I added the data_provider.rb to have easy liquid like access to the data of my site. Now I have some fun with slim, jekyll and liquid. Maybe it is helpfull to someone.

About

A gem that adds slim-lang support to Jekyll.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Ruby 100.0%