How to install and use Slim template engine with Middleman

好久不见. 提交于 2019-12-04 12:47:02

问题


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

  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



回答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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!