Wordpress 与 Haml/Sass

发布于 2024-09-30 07:05:33 字数 526 浏览 3 评论 0原文

使用过 Haml

我真的很希望能够使用 Haml 和 Sass在 WordPress 网站的上下文中,虽然我知道各种 PHP 实现的存在,大多数看起来不活跃或有问题。这里有人成功地在 WordPress 网站上使用 Haml 和 Sass 吗?我在 WordPress 模板文件(支持 Wordpress 主题的 .php 文件)和 Wordpress 编辑器的 HTML 编辑模式中提出这个问题,尽管后者远没有那么重要。

注意:我知道我可以安装适当的 ruby​​ gems 并从 Haml/Sass 源编译我自己的 HTML/CSS;我正在寻找的是更符合我在 Rails 中习惯的功能,其中编译的 HTML/CSS 是根据每个请求自动生成的(缓存行为也很好,但肯定不是必需的) )。

提前致谢!

Having used Haml and Sass for a few Rails side projects, I've found that they speed up my frontend development tremendously. However, I haven't found a Rails blogging platform that's as robust or familiar to clients as Wordpress, so that's still generally my go-to for projects that require a light website with basic CMS / blogging functionality. (I've looked into Radiant, Mephisto, etc, and while I certainly appreciate suggestions of Rails blog engines, that's not really the question I'm looking to answer here.)

I'd really like to be able to use Haml and Sass in the context of a Wordpress site, and while I'm aware of the existence of various PHP implementations, most seem inactive or buggy. Has anyone here had success using Haml and Sass with Wordpress sites? I'm asking this both in the context of Wordpress template files (the .php files that power a Wordpress theme) and in the HTML editing mode of the Wordpress editor, though the latter is far less important.

Note: I'm aware that I can just install the appropriate ruby gems and compile my own HTML/CSS from the Haml/Sass source; what I'm looking for is something more along the lines of the functionality I'm used to in Rails, where the compiled HTML/CSS is autogenerated on a per-request basis (caching behaviour would also be nice, but is certainly not required).

Thanks in advance!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(9

坦然微笑 2024-10-07 07:05:34

Haml 在运行时需要 Ruby。因此您将无法将其用于 WordPress 模板。因此,您必须依赖 PHP 实现。

对于Sass,可以使用控制台工具Sass --watch进行自动编译。请参阅此博文。此外,还有指南针应用,它为您提供所有指南针功能在一个方便的 OSX 应用程序中。

Haml requires Ruby at runtime. So you will not be able to use that for Wordpress templates. Thus, you have to rely on a PHP implementation.

For Sass, you can use the console tool Sass --watch for auto-compilation. See this blog post. Additionally, there is the Compass App, which gives you all the Compass features in a convenient OSX app.

情话已封尘 2024-10-07 07:05:34

对于 HAML,现在有 http://haml-to-php.com。 phamlp太破了。如果不从头开始重写它,你就无法让它工作。请参阅 github.com/MarcWeber/phamlp。最终,一个像样的 SASS 实现也将被创建。

For HAML there is http://haml-to-php.com now. phamlp is too broken. Without rewrtiing it from scratch you can't make it work. See github.com/MarcWeber/phamlp. Eventually a decent SASS implementation will be created as well.

泪痕残 2024-10-07 07:05:34

如果你不害怕边缘,你可以尝试这个Wordpress插件: https:// github.com/sxua/HAML-SASS-for-Wordpress
稍后将在 Github 上提供更多详细信息。

If you don't afraid of edge, you can try this plugin for Wordpress: https://github.com/sxua/HAML-SASS-for-Wordpress.
More details soon at Github.

走过海棠暮 2024-10-07 07:05:34

不像根据每个请求在服务器上运行它那么酷,但是FWIW,我构建了一个脚本来在我的开发机器上自动编译我的 haml/sass ,所以至少我可以使用 haml/sass 轻松生成我的 WordPress 模板和 CSS: https://gist.github.com/1169586 尽情享受!

Not as cool as running it on the server on a per-request basis, but FWIW, I built a script to auto-compile my haml/sass on my dev machine so at least I can use haml/sass to easily generate my Wordpress templates and CSS: https://gist.github.com/1169586 Enjoy!

千紇 2024-10-07 07:05:34

我意识到这是一个较旧的线程,但我来到这里,所以其他人也可能如此。有许多 gulp 和 grunt 插件可以做到这一点,但是如果您使用的是 OSX,CodeKit 非常方便。

在此 SO thread 上的人们,提供有关如何编译 haml 的建议在 php 文件中。

I realise this is an older thread, but I landed here so others might too. There are a number of gulp and grunt plugins that will do this, however if you're on OSX, CodeKit is super convenient.

And the folks over on this SO thread, offer suggestions on how to compile haml in php files.

遗心遗梦遗幸福 2024-10-07 07:05:33

您可能想查看 WORDLESS
https://github.com/welaika/wordless

是一个Wordpress插件,自带compass/SASS 、CoffeScript 和 Haml。

You probably want to check out WORDLESS
https://github.com/welaika/wordless

It's a Wordpress plug-in that comes with compass/SASS, CoffeScript, and Haml.

烂人 2024-10-07 07:05:33

对于定制需求较低的网站,我也有同样的看法。我已经习惯了 Haml 和 Sass,以至于回到 HTML 和 CSS 似乎很痛苦。 PHamlP 获得了一些好评,特别是因为它支持 Sass:(http://code.google.com/p/phamlp/)。尽管如此,真实的东西还是无可替代的。

如果这是我的项目,我会考虑使用 Compass,并在进行更改时进行指南针更新。 Sass 太好了,不容错过。 Haml 是您的日常面包和黄油,但 Sass 确实可以帮助您让页面唱歌。它建议您可能从未想到过样式表重构。

I'm in the same boat with respect to the sites with a low demand for customization. I'm so used to Haml and Sass that going back to HTML and CSS seems painful. PHamlP has gotten some good reviews, especially because it supports Sass: (http://code.google.com/p/phamlp/). Still, there's no substitute for the real thing.

If it were my project, I'd consider Compass and just do a compass update when I made changes. Sass is too good to pass up. Haml is your daily bread and butter, but Sass can really help you make pages sing. It suggests stylesheet refactorings you might never have thought of otherwise.

冬天旳寂寞 2024-10-07 07:05:33

这是我刚刚发布的一个新插件: http://wordpress.org/extend/plugins/wordpress -sass/

它确实使用了 PHamlP,尽管有其缺点,但至少它不需要服务器上的 Compass。

该插件的实现非常简单,每当 style.scss 文件(或您选择的任何名称)更新时,它都会自动重新生成您的 style.css

更多信息:http://blogrescue.com/2011/12/sass-for-wordpress /

埃德

Here is a new plugin I just released: http://wordpress.org/extend/plugins/wordpress-sass/

It does use PHamlP, with all its warts, but at least it doesn't require Compass on the server.

The plugin is very simple to implement and automatically regenerates your style.css whenever the style.scss file (or whatever you choose to name it) is updated.

More info: http://blogrescue.com/2011/12/sass-for-wordpress/

Ed

时间海 2024-10-07 07:05:33

我创建了一个开发工具包,使 HAML、PHP 和 SASS 与 WordPress 主题的使用变得轻而易举。它还会编译您的 JavaScript!所有内容最终都会编译成 WordPress 主题。当我遇到这个问题时,这就是我的解决方案。我希望这会有所帮助:

https://github.com/zachfeldman/wordpress-haml-sass< /a>

I created a development toolkit to make using HAML, PHP, and SASS a breeze with WordPress themes. It also compiles your JavaScript! Everything ends up compiled together into a WordPress theme. When I came across this question, this was my solution. I hope this helps a bit:

https://github.com/zachfeldman/wordpress-haml-sass

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文