承接 icanboogie/render 相关项目开发

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

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

icanboogie/render

Composer 安装命令:

composer require icanboogie/render

包简介

Renders templates with a variety of template engines.

README 文档

README

Release Code Coverage Downloads

An API to render templates with a variety of template engines.

Installation

composer require icanboogie/render

Render engines

Templates may be rendered with a variety of template engines.

The following example demonstrates how to create an engine provider with the builtin engine for PHP templates.

<?php

/* @var ICanBoogie\Render\PHPEngine $engine */
/* @var string $template_pathname */
/* @var mixed $content */
/* @var array<string, mixed> $variables */

$rendered = $engine->render($template_pathname, $content, $variables);

Note: Currently, the package only provides an engine to render PHP templates, the available engine can be extended with third parties packages such as render-engine-markdown or render-engine-patron.

Render engine providers

Render engines are obtained through engine providers. The following providers are builtin:

The following examples demonstrates how to obtain an engine for a .php extension from an immutable provider.

<?php

use ICanBoogie\Render\EngineProvider\Immutable;
use ICanBoogie\Render\PHPEngine;

$engines = new Immutable([ '.php' => new PHPEngine() ]);
echo $engines->engine_for_extension('.php')::class; // ICanBoogie\Render\PHPEngine

All engine providers are traversable, this feature can be used to collect the supported extensions:

<?php

/* @var EngineProvider $engines */

$extensions = array_keys(iterator_to_array($engines));

echo implode(', ', $extensions); // .php

The pathname of the template being rendered

Engines should use the Engine::VAR_TEMPLATE_PATHNAME variable to define the pathname of the template being rendered, so that it is easy to track which template is being rendered and from which location.

Template resolver

A template resolver tries to match a template name with an actual template file. A set of paths can be defined for the resolver to search in.

Renderer

A Renderer instance is used to render a template with a subject and options. An engine collection and a template resolver are used to find suitable templates for the rendering.

Continuous Integration

The project is continuously tested by GitHub actions.

Tests Static Analysis Code Style

Code of Conduct

This project adheres to a Contributor Code of Conduct. By participating in this project and its community, you're expected to uphold this code.

Contributing

See CONTRIBUTING for details.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: BSD-3-Clause
  • 更新时间: 2014-11-07

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固