How to install and use Slim template engine with M

2019-03-20 20:20发布

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?

3条回答
▲ chillily
2楼-- · 2019-03-20 21:12

Bundler tip: you can also include multiple gems at once using Bundler.require. If you have gems in groups, you can include them as such: Bundler.require :group1, :group2 ...

查看更多
戒情不戒烟
3楼-- · 2019-03-20 21:14

The middleman-slim project by yterajima is helpful in this regard.

Install is very easy.

$ gem install middleman
$ gem install middleman-slim
$ middleman init PROJECT_NAME --template slim
查看更多
叼着烟拽天下
4楼-- · 2019-03-20 21:21

So here we go... after much reading and searching google for examples I think I figured it out.

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
查看更多
登录 后发表回答