从Rails外部的HAML内部渲染HAML部分 [英] Rendering HAML partials from within HAML outside of Rails

查看:65
本文介绍了从Rails外部的HAML内部渲染HAML部分的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用HAML为网站生成一些静态html页面,我想将常见组件分解为多个部分,就像在Rails中一样,可以将它们包含在多个页面中.但是,我不想使用整个Rails堆栈来执行此操作,因为这似乎有些过分.

I'm using HAML to generate some static html pages for a site, and I was wanting to split out common components into partials that I can include in multiple pages, just like in Rails. However I don't want to use the whole Rails stack to do this as it seems like overkill.

我已经在Internet上四处张望,但没有发现任何东西,总比做像这样的事情要好:

I've looked around on the Internet but haven't found anything, better than just doing something like:

Haml::Engine.new(IO.read("header.haml")).render

在HAML中是否有更好的方法来包含所谓的局部变量?我缺少的现有过滤器或命令?

Is there a nicer way of including so-called partials from within HAML? An existing filter or command that I'm missing?

推荐答案

最好结合使用haml& sass与建立静态网站的工具.这里是一些链接:

It's best to combine haml & sass with a tool for building static websites. Here's some links:

  • StaticMatic
  • Serve
  • Haml Jekyll -- a fork of Jekyll that supports haml.
  • Middleman

我在博客中使用jekyll,但是如果您不构建博客,则可能不适合您的需求.

I'm using jekyll for my blog, but if you're not building a blog it's probably not appropriate for your needs.

这篇关于从Rails外部的HAML内部渲染HAML部分的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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