websemantics / lcss2php
方便地从多个 Less / Scss 源文件中提取变量声明,并返回 PHP 关联数组。
1.0.4
2018-01-03 22:41 UTC
Requires
- php: >=5.3.0
- leafo/scssphp: 0.7.*
- oyejorge/less.php: 1.7.*
This package is not auto-updated.
Last update: 2024-09-26 04:57:39 UTC
README
╭────────▞────────╮
│ │
│ ╭─────────╮ │
│ │ │ │
┬ ╭─╮╭─╮╭─╮ ╭─╮╭─╮╭─╮╭─╮ ┃ │ ░ ░░░ │ ┃ ┬╭─╮ ╭─╮┬ ┬╭─╮ ╭─╮┬ ┬╭─╮
│ ├┤ ╰─╮╰─╮ ╰─╮│ ╰─╮╰─╮ ┃ │ ░░░░░ │ ┃─┤├─╯ ├─╯├─┤├─╯ ├─╯├─┤├─╯
┴─╯╰─╯╰─╯╰─╯ ╰─╯╰─╯╰─╯╰─╯ ┃ ╰─────────╯ ┃ ┴┴ ┴ ┴ ┴┴ ┴ ┴ ┴┴
╭──────────────────────────────────┤ ├──────────────────────────────────╮
│ ◯ ◯ ◯ ◯ ◯ ◯ ◯ ◯ │ ▯ ▯ ▯ ▯ ▯ ▯ │ ◯ ◯ ◯ ◯ ◯ ◯ ◯ ◯ │
╰──┬┬─────┬┬─────┬┬─────┬┬─────┬┬──┤ ├───┬┬─────┬┬─────┬┬─────┬┬─────┬┬─╯
││ ││ ││ ││ ││ │ ╭───╮ │ ││ ││ ││ ││ ││
───┤├─────┤├─────┤├─────┤├─────┤├──┤ │───│ ├───┤├─────┤├─────┤├─────┤├─────┤├────
─┴┴ ─ ┴┴ ─┴┴ ─ ┴┴─ ─┴┴ │ │ │ │ ┴┴ ─ ─┴┴─ ┴┴─ ─┴┴ ─ ┴┴─
╰──────╯ ╰──────╯
一个简单的库,可以从多个
Less
/Scss
源文件中提取变量声明,并返回一个PHP
关联数组。
安装
1- 使用 Composer
按以下方式安装,
composer require websemantics/lcss2php
入门
将文件列表(Less
、Scss
或混合)传递给新创建的 Lcss2php
类实例。使用 all
方法获取所有变量的列表。
$files = ['/usr/etc/variables.less', '/usr/etc/_variables.scss']; $lcss2php = new Lcss2php($files); $variables = $lcss2php->all();
默认情况下,返回所有变量类型,例如,Color
、Dimension
等。您可以使用 ignore
函数从最终变量列表中过滤掉某些类型,
$variables = (new Lcss2php($files))->ignore(['Color', 'Dimension'])->all();
请注意,对于每种语言(Less
、Scss
),都有两种不同的变量类型。要获取所有类型的列表,请查看 lcss2php/src/Node/Type.php
中的 Type
类。
示例
快速运行预期结果;以下是一个 Scss
示例代码,
$green: #24ce7b !default; $blue: #38b5e6 !default; $orange: #f48714 !default; $red: #f6303e !default; $brand-success: $green; $brand-info: $blue; $brand-warning: $orange; $brand-danger: $red; $spacer: 1rem !default; $spacer-x: $spacer !default; $spacer-y: $spacer !default;
将被转换为,
[ "green" => "#24ce7b" "blue" => "#38b5e6" "orange" => "#f48714" "red" => "#f6303e" "brand-success" => "#24ce7b" "brand-info" => "#38b5e6" "brand-warning" => "#f48714" "brand-danger" => "#f6303e" "spacer" => "1rem" "spacer-x" => "1rem" "spacer-y" => "1rem" ]
支持
如果这个项目对您有帮助,请 ⭐ 收藏此仓库,以示支持或仅仅因为很棒 :)!
需要帮助或有问题?请在 [StackOverflow](https://stackoverflow.com/questions/tagged/lcss2php websemantics) 上发布。
请不要使用问题跟踪器来寻求支持/提问。
贡献
接受对该项目的反馈、错误报告,甚至更好的是拉取请求。
开源
以下项目已用于本项目的制作,感谢您!
许可证
MIT 许可证 版权所有 (c) Web Semantics, Inc.