programmatordev/kinky
Composer 安装命令:
composer require programmatordev/kinky
包简介
Inky email templating language for Kirby CMS
README 文档
README
Converts simple HTML tags into the complex table required for emails. Oh là là!
Table of Contents
TL;DR
Building HTML emails is painful.
You're stuck using archaic table-based layouts, and you constantly have to fight against inconsistent rendering across outdated email clients (like Outlook). Modern web standards? Mostly ignored.
To make life easier, this plugin was created so you can write cleaner code and still get reliable results across all major email clients.
How it Works
This plugin streamlines HTML email development by integrating a transpiler and inliner workflow built around Inky.
It uses a transpiler that converts Inky's custom components into table-based HTML, ensuring compatibility with legacy email clients.
After that, it passes the output through a CSS inliner that merges both Inky's default styles and any custom CSS into inline styles.
The result is clean, reliable HTML emails that render consistently across major clients like Outlook, Gmail, and Apple Mail — without giving up modern development convenience.
Example
Simple usage of Inky base components (it is recommended to include the body class to enable responsive columns):
<!-- templates/emails/email.html.php --> <wrapper class="body"> <container> <row> <columns>Kinky</columns> <columns>Oh là là</columns> </row> </container> </wrapper>
Transformed HTML (clean example without the whole document and CSS inlining):
<table class="body wrapper" align="center"> <tr> <td class="wrapper-inner"> <table align="center" class="container"> <tbody> <tr> <td> <table class="row"> <tbody> <tr> <th class="small-12 large-6 first columns"> <table> <tr> <th>Kinky</th> </tr> </table> </th> <th class="small-12 large-6 last columns"> <table> <tr> <th>Oh là là</th> </tr> </table> </th> </tr> </tbody> </table> </td> </tr> </tbody> </table> </td> </tr> </table>
Requirements
- PHP
8.2or higher; - PHP
domextension; - Kirby CMS
5.0or higher.
Installation
Install the plugin via Composer:
composer require programmatordev/kinky
Usage
A global kinky() function is available to create and send emails.
transformTemplate
kinky()->transformTemplate(string $template, array $data = []): string
Returns the final transformed HTML from the given $template.
Take into account that email templates must be located in the /site/templates/emails/ directory.
Note
Check the documentation regarding how emails work in Kirby.
You can pass data into the template using the $data parameter.
This method can be useful to help creating and previewing email templates:
// templates/default.php // the template will be located at /site/templates/emails/notification.html.php <?= kinky()->transformTemplate('notification', [ 'name' => 'Kinky', 'text' => 'Oh là là' ]); ?>
email
use Kirby\Email\Email; kinky()->email(mixed $preset = [], array $props = []): Email
This method is basically a wrapper around the existing kirby()->email() method, so it works the same way.
The only difference is that it transpiles and inlines the Inky components and CSS for you.
// note that the "template" property is required kinky()->email([ 'template' => 'notification', // required 'from' => 'from@email.com', 'to' => 'to@email.com', 'subject' => 'Kinky Plugin', 'data' => [ 'name' => 'Kinky', 'text' => 'Oh là là' ] ]);
It is basically the same as doing the following:
kirby()->email([ 'from' => 'from@email.com', 'to' => 'to@email.com', 'subject' => 'Kinky Plugin', 'body' => [ 'html' => kinky()->transformTemplate('notification', [ 'name' => 'Kinky', 'text' => 'Oh là là' ]) ] ]);
Note
Check the documentation regarding how emails work in Kirby.
Cookbook
Custom CSS
To use your own custom CSS, you can include a <style> element in the template and all selectors will be inlined for you.
Template:
<style> p { background-color: #000000; color: #ffffff; font-size: 32px; } .small { font-size: 16px; } </style> <wrapper class="body"> <p class="text">Kinky <span class="small">Oh là là!</span></p> </wrapper>
Result:
<table class="body wrapper" align="center"> <tr> <td class="wrapper-inner"> <p style="background-color: #000000; color: #ffffff; font-size: 32px;"> Kinky <span class="small" style="font-size: 16px;">Oh là là</span> </p> </td> </tr> </table>
Acknowledgments
Thank you to the authors of these libraries that make this plugin possible:
Contributing
Any form of contribution to improve this library (including requests) will be welcome and appreciated. Make sure to open a pull request or issue.
License
This project is licensed under the MIT license. Please see the LICENSE file distributed with this source code for further information regarding copyright and licensing.
programmatordev/kinky 适用场景与选型建议
programmatordev/kinky 是一款 基于 CSS 开发的 Composer 扩展包,目前已累计 4 次下载、GitHub Stars 达 1, 最近一次更新时间为 2025 年 04 月 14 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「email」 「kirby」 「inky」 「kirby-plugin」 「kirby-cms」 「email-template」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 programmatordev/kinky 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 programmatordev/kinky 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 programmatordev/kinky 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Easy responsive e-mails using Foundation and Inky
Foundation Inky email templates in Laravel
PHP Implementation of ZURB's Foundation for Email parser - Based on thampe/inky
Foundation Inky email templates in Laravel
Zero-dependency global `kirbylog()` helper for any content
Courier offers a convenient and painless solution for creating emails tailored for your Kirby website.
统计信息
- 总下载量: 4
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 25
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-04-14