问题
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?
回答1:
So here we go... after much reading and searching google for examples I think I figured it out.
To get Slim working with Middleman
- Add
gem "slim"
to your project's gemfile - go to command line, in your project folder and
gem install bundler
- In the config.rb file add
require 'slim'
- Start the middleman server to test it
回答2:
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
回答3:
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 ...
来源:https://stackoverflow.com/questions/15626845/how-to-install-and-use-slim-template-engine-with-middleman