Search code examples
rubyslim-langmiddleman

How to install and use Slim template engine with Middleman


I'm new to Middleman and ruby in general.

I've installed Ruby I've installed Middleman and the gems to get it running.

I need to use slim instead of the default template system.

So I installed the Slim gem. Slim's website only says that I need to require 'slim' in order to get it to work.

The middleman website says I only need add the template engine to the config.rb file, but it gives no examples...

For someone with no ruby background, this is no help.

I looked for several config.rb on git and they all have:

require 'slim'

And

# Set slim-lang output style
Slim::Engine.set_default_options :pretty => true

# Set template languages
set :slim, :layout_engine => :slim

I added that to my config.rb file and created the layout.slim and the index.html.slim

When I refresh my local server I get:

Not Found

`/' not found.

I have middleman installed with Boilerplace. I'm not sure if there are more files that I need to change, but I can't find any good resources online, which is odd.

Could anyone give me some direction as to what I'm missing?


Solution

  • To get Slim working with Middleman

    1. Add gem "slim" to your project's gemfile
    2. go to command line, in your project folder and gem install bundler
    3. In the config.rb file add require 'slim'
    4. Start the middleman server to test it