shineunited/conductor-twig-addon 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

shineunited/conductor-twig-addon

最新稳定版本:1.0.0

Composer 安装命令:

composer require shineunited/conductor-twig-addon

包简介

Addon for Conductor to support building files using Twig templates.

README 文档

README

License Latest Version PHP Version Main Status Release Status Develop Status

Description

Add support for Twig templates to the Conductor generator/blueprint framework.

Installation

To add conductor-twig-addon, the recommended method is via composer.

$ composer require shineunited/conductor-twig-addon

Usage

NamespaceProvider Capability

The NamespaceProvider capability registers Twig template include paths.

Example Plugin

The plugin must implement Capable and provide the NamespaceProvider capability.

<?php

namespace Example\Project;

use Composer\Composer;
use Composer\IO\IOInterface;
use ShineUnited\Conductor\Addon\Twig\Capability\NamespaceProvider;
use ShineUnited\Conductor\Capability\BlueprintProvider;

class ComposerPlugin implements PluginInterface, Capable {

	public function activate(Composer $composer, IOInterface $io): void {
		// ...
	}

	public function deactivate(Composer $composer, IOInterface $io): void {
		// ...
	}

	public function uninstall(Composer $composer, IOInterface $io): void {
		// ...
	}

	public function getCapabilities(): array {
		return [
			NamespaceProvider::class => ExampleNamespaceProvider::class,
			BlueprintProvider::class => ExampleBlueprintProvider::class
		];
	}
}

Example Provider

The provider must implement the capability, and return a list of TwigNamespaceInterface objects.

<?php

namespace Example\Project;

use ShineUnited\Conductor\Addon\Twig\Capability\NamespaceProvider;
use ShineUnited\Conductor\Addon\Twig\Loader\TwigNamespace;

class ExampleNamespaceProvider implements NamespaceProvider {

	public function getNamespaces(): array {
		return [
			new TwigNamespace('path/to/template/dir', 'optional-namespace'),
			new TwigNamespace('path/to/global/templates') // load in root namespace
		];
	}
}

These namespaces can then be used in a blueprint provider with the TwigBlueprint.

<?php

namespace Example\Project;

use ShineUnited\Conductor\Capability\BlueprintProvider;
use ShineUnited\Conductor\Addon\Twig\Blueprint\TwigBlueprint;

class ExampleBlueprintProvider implements BlueprintProvider {

	public function getBlueprints(): array {
		return [
			new TwigBlueprint('path/to/file.html', '@namespace/template.twig'),
			new TwigBlueprint('another/file.html', 'global.twig')
		];
	}
}

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2022-11-16