带有使用Grunt.js的部分的静态HTML编译 [英] Static HTML compilation with partials using Grunt.js

查看:118
本文介绍了带有使用Grunt.js的部分的静态HTML编译的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在寻找能让我使用Grunt预编译静态网站的东西。它需要有偏分量,所以我可以在页面中包含一些常见的页眉/页脚。



到目前为止,我只找到 Jade ,里面有一个grunt插件,这个用于Grunt的插件,它将Dust.js模板编译为静态HTML。我不太喜欢Jade的语法,而Grunt的Dust插件不太理想。

是否有静态的HTML模板语言,支持Grunt / Gulp,不会偏离常规HTML,并且仍然活跃?

解决方案

我发现这个名为 grunt-includes 的插件 。我一直在寻找对你的问题的答案。这是我见过的第一个似乎很容易使用的程序。所有其他人似乎可能拥有这个功能,但是做了20倍其他的事情,所以他们看起来像是这个工作的错误工具。

对我而言,缺少的一件事是为相对路径加上前缀的能力。我正在与谦虚的开发者交谈,这正在变成一个更好的选择。



更新:有一个 grunt-includes-replace 几乎同样简单并可以为相对路径加上前缀IE:它可以让你传入变量。

I've been looking all over for something that will let me precompile static websites using Grunt. It needs to have partials, so I can include things like a common header/footer across the pages.

So far, I've only really found Jade, which has a grunt plugin, and this plugin for Grunt that compiles Dust.js templates to static HTML. I don't really like Jade's syntax, and the Dust plugin for Grunt is less than ideal.

Are there any static HTML templating languages with Grunt/Gulp support that don't deviate too much from regular HTML, and are still active?

解决方案

I found this plugin named grunt-includes. I've been looking for an answer to your question forever. This is the first one I've seen that seems easy to use. All the others seem to maybe have this feature but do 20x other things so they seem like the wrong tool for the job.

The one thing this is missing for me is the ability to prefix relative paths. I'm talking to the developer of modest which is becoming a better option.

UPDATE: There's a grunt-includes-replace that is almost as simple and can prefix relative paths. IE: it lets you pass in variables.

这篇关于带有使用Grunt.js的部分的静态HTML编译的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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