如何通过 Middleman 安装和使用 Slim 模板引擎 [英] How to install and use Slim template engine with Middleman

查看:39
本文介绍了如何通过 Middleman 安装和使用 Slim 模板引擎的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

总的来说,我是 Middleman 和 ruby​​ 的新手.

I'm new to Middleman and ruby in general.

我已经安装了 Ruby我已经安装了 Middleman 和 gems 来让它运行起来.

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

我需要使用 slim 而不是默认的模板系统.

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

所以我安装了 Slim gem.Slim 的网站只说我需要slim"才能让它工作.

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

中间人网站说我只需要将模板引擎添加到config.rb文件中,但没有给出示例...

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.

我在 git 上找了几个 config.rb,它们都有:

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

require 'slim'

还有

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

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

我将它添加到我的 config.rb 文件并创建了 layout.slim 和 index.html.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.

我在 Boilerplace 中安装了中间人.我不确定是否还有更多文件需要更改,但我在网上找不到任何好的资源,这很奇怪.

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?

推荐答案

所以我们开始吧……经过大量阅读和谷歌搜索示例后,我想我明白了.

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

让 Slim 与 Middleman 合作

To get Slim working with Middleman

  1. gem "slim" 添加到项目的 gemfile 中
  2. 转到命令行,在您的项目文件夹和 gem install bundler
  3. 在 config.rb 文件中添加 require 'slim'
  4. 启动中间人服务器进行测试
  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

这篇关于如何通过 Middleman 安装和使用 Slim 模板引擎的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆