承接 kanata-php/mustachio 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

kanata-php/mustachio

最新稳定版本:0.0.2

Composer 安装命令:

composer require kanata-php/mustachio

包简介

Stubs processor.

README 文档

README

Tests

Mustachio

This lib parse some template or stub. You can use it as a PHP terminal command or in your code.

Kudos to Mustache!

Install

CLI

To use as a CLI command, you can download the phar file:

Important: remember to replace the version-number!

Library

Install via composer:

composer require kanata-php/mustachio

Usage

App Service

Stub Parser

This can serve as a file stub parser or a very simple template engine. By default, it uses mustache to parse the input file.

use Mustachio\Service as Stache;
$parsedContent = Stache::parse('my content with {{PLACEHOLDER}}', ['PLACEHOLDER' => 'value']);
// output: my content with value

Line Replacement

This can be used to replace/remove lines in files.

use Mustachio\Service as Stache;
Stache::replaceFileLineByCondition(
    file: '/path/to/file',
    conditions: [
        fn($l) => strpos($l, 'identifier-1') !== false,
        fn($l) => strpos($l, 'identifier-2') !== false,
    ],
    values: [
        'replacement-for-identifier-1',
        'replacement-for-identifier-2',
    ],
    toRemove: function ($l) {
        return strpos($l, 'identifier-to-remove') !== false;
    },
);
// output: update the original file

Cli Phar Usage

Stub Parser

This can process input files giving back the output file parsed with the given placeholders.

php bin/stache "/path/to/my.stub" "/path/to/my.php" "PLACEHOLDER:value;PLACEHOLDER2:value2"

Tests

vendor/bin/pest

统计信息

  • 总下载量: 219
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 1
  • 依赖项目数: 1
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: Unknown
  • 更新时间: 2022-11-13