stillat/blade-parser
Composer 安装命令:
composer require stillat/blade-parser
包简介
README 文档
README
Blade Parser is library for Laravel that makes it easy to parse, analyze, and manipulate Blade templates.
The library is composed of many major components:
- Parser: A Blade parser that produces a list of nodes, which can be analyzed to help make decisions surrounding a template.
- Documents: A powerful abstraction that makes it much simpler to interact with the details of a single parsed Blade template.
- Workspaces: A simple set of APIs that make it effortless to work with multiple parsed Blade templates at once.
- Compiler: A highly configurable Blade compiler implementation, with support for precompilers, extensions, and existing third-party packages.
- Validator: An extensible system for validating Blade documents, with default validators capable of detecting unpaired conditions, invalid component parameter spacing, and much more.
Simple to Use
Parsing Blade templates is incredibly simple using the Documents API. As an example, this is all that is needed to parse a template:
<?php use Stillat\BladeParser\Document\Document; $template = <<<'BLADE' Hello, {{ $world }} BLADE; $document = Document::fromText($template);
The Document class provides a powerful abstraction, making it simple to quickly retrieve information about a template.
For instance, if we wanted to extract all the components from our template we could do this:
<?php // Do something with all component tags in the template. $document->getComponents() ->each(fn($node) => ...);
If we were only interested in a component named alert, we could instead use:
<?php // Find all "alert" components. $document->findComponentsByTagName('alert') ->each(fn($node) => ...);
These examples hardly scratch the surface, and you are encouraged to read through the Documentation.
Built-in Validation Command
This library also ships with a configurable blade:validate Artisan command which can be used to validate all Blade templates within a project.
To configure the command, you will need to publish its configuration files using the following command:
php artisan vendor:publish --tag=blade
To run the validation against your project, you can issue the following Artisan command:
php artisan blade:validate
If any validation issues were detected they will be displayed in your terminal.
There are many configuration options available, and if you'd like to learn more you can find them documented in the Configuring the Validate Command article.
License
This parser library is open-sourced software licensed under the MIT license.
stillat/blade-parser 适用场景与选型建议
stillat/blade-parser 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 1.58M 次下载、GitHub Stars 达 146, 最近一次更新时间为 2022 年 11 月 18 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 stillat/blade-parser 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 stillat/blade-parser 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 1.58M
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 146
- 点击次数: 12
- 依赖项目数: 8
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2022-11-18
