內容簡介
PHAMLP for WordPress 讓你可以使用 HAML 模板系統來創建主題。HAML 取代了大多數 HTML/PHP 模板系統的混亂標籤,使用更清晰、分層的標記語言。
這是一個簡單的外掛程式,只會解析 haml、sass/scss 和 PHP 程式碼,然後將它們轉換為相應的 PHP 原始碼和呈現。
它不包含任何像是 link_to、image_tag 等 rail 的豐富模板標籤。
如果你需要這些功能,你應該看看 wordless 外掛程式。
只要啟用 PHAMLP for WordPress,任何普通的 HTML/PHP 主題都可以使用。但是構成 WordPress 主題的各個模板,從 index.php 到 author.php,都可以替換為相應的 .php.haml 檔案,PHAMLP for WordPress 會處理它們。
如果啟用了它,它還會檢查 sass/scss 樣式表檔案,編譯它們並替換最終輸出的連結。
像正常連結任何其他 .css 檔案一樣。
這個外掛程式會將 haml 和 sass 檔案解析為快取檔案,分別存在 wp-content/phphaml4pw/tmp/php 和 wp-content/phphaml4pw/tmp/css 中,由於明顯的原因,這些資料夾需要可寫入您的網頁伺服器。
由於 PHPHaml 不支援完整的 HAML 語法,如果你有任何語法問題,可以參考 https://github.com/Baldrs/phphaml。
Sass 解析器使用的是 phamlp 的解析器 (http://code.google.com/p/phamlp/)。
HAML 範例
想要範例 HAML 主題,請參考 themes/ 資料夾。
有兩種製作主題的方式:
a) Ruby 的方式是使用佈局。在你的主題中放置 layout.php.haml 文件,裡頭主要包含 WP 的標頭和頁尾。
b) WP 的方式是使用單獨的 header.php 和 footer.php 文件。由於這些文件是靜態包含的,它們的名稱不能更改 (也就是無法使用 header.haml,抱歉!)。
作為解決方案,我們實現了 partials,只需在 index.php.haml 中調用 render("header")/render("footer"),就可以包含 _header/_footer.php.haml。
content_for 目前不能運行,抱歉!
授權
PHPHaml4WP 是 Phamlp 的 WordPress 分支,因此可以根據 ISC 授權 使用。
PHPHAML 的授權包含在分發中。
Sass 解析器取自 http://code.google.com/p/phamlp/,適用新 BSD 授權。
包含的主題源自於預載的 TwentyTen 主題,繼承了原始主題的 GPL 授權。
外掛標籤
開發者團隊
② 後台搜尋「seedsugar-phphamlsass for WordPress」→ 直接安裝(推薦)
原文外掛簡介
PHAMLP for WordPress enables theme creation using the HAML template system. HAML replaces the tag soup of most HTML/PHP templates with a cleaner, hierarchical markup language.
This is a simple plugin that only parses haml and sass/scss with included php code to their respective php source and renders that.
It DOES NOT include any of rail’s sophisticated templating tags, like link_to, image_tag etc..
If you want something like that you should take a look at the wordless plugin.
Any plain HTML/PHP theme will work while PHAMLP for WordPress is enabled. But the individual templates that make up a WordPress theme, from index.php to author.php, can be replaced with a corresponding .php.haml file and PHAMLP for WordPress will process them.
If enabled it will also check for sass/scss stylesheet files, compile them and replace the links in the final output.
Just link to them normally like you would to any other .css file.
The plugin parses haml and sass files into cached files in wp-content/phphaml4pw/tmp/php and wp-content/phphaml4pw/tmp/css respectively, for obvious reasons these folders need to be writable by your webserver.
As PHPHaml does not support the complete HAML syntax, take a look at https://github.com/Baldrs/phphaml for any syntax questions you might have.
Sass parser uses the parser from phamlp (http://code.google.com/p/phamlp/).
HAML Example
For an example HAML theme check the themes/ folder.
There are two ways you can make a theme:
a) The ruby way is to use layouts. For that place a layout.php.haml file in your theme which basically comprises WP’s header and footer.
b) The WP way is to have seperate header.php and footer.php files. Since these are statically included by WP their names cannot be changed (meaning no header.haml – sorry!).
As a workaround, I’ve implemented partials, just call render(“header”)/render(“footer”) in your index.php.haml and _header/_footer.php.haml will be included.
Content_for does not yet work – sorry!
Licenses
PHPHaml4WP a fork of Phamlp for wordpress, and is therefore available under the ISC license.
PHPHAML’s license is included in the distribution.
Sass Parser is from http://code.google.com/p/phamlp/ which uses the New BSD License.
The included themes are derived from the TwentyTen theme that ships with WordPress and inherit the original theme’s GPL license.
