piotr-cz/twig-extensions-joomla 问题修复 & 功能扩展

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

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

piotr-cz/twig-extensions-joomla

Composer 安装命令:

composer require piotr-cz/twig-extensions-joomla

包简介

Twig - Joomla Framework Language bridge

README 文档

README

Extensions provide filters to allow using of Joomla-Framework packages such as Language package in Twig templates.

Installation

Add "piotr-cz/twig-extensions-joomla": "~1.0" to require block in your composer.json and run composer install.

{
	"require": {
		"piotr-cz/twig-extensions-joomla": "~1.0"
	}
}

Text extension

It's assumed that you will use Composer to handle autoloading.

Setup

Add the extension to the twig environment:

// Configure Twig
$loader = new \Twig_Loader_Filesystem(JPATH_TEMPLATES);
$twig = new \Twig_Environment($loader, $options = array());

// Register Extension
$twig->addExtension(new \TwigJoomla\Extension\TextExtension);

// Render Template
$template = $twig->loadTemplate('test.twig');
echo $template->render();

Usage

Extension is able to call any public method of Text (like Text::_(), Text::sprintf(), ...).

Accepted Parameters

  • $method Text method
  • Text arguments

The _ method (default)

Twig Template:

{{ "IMADEIT" | jtext }}

Language file:

IMADEIT 	= "I made it!"

Result:

I made it!

The sprintf method

Twig template

{{ "HELLOW" | jtext('sprintf', 'World') }}

Language file

HELLOW		="Hello %s!"

Result

Hello World!

Date extension

This extension allows to use localised date output and instead of PHP intl extension uses Language package. Crucial functions imported from of JDate package.

Setup

$twig->addExtension(new \Twigoomla\Extension\DateExtension($config->get('timezone')));

Usage

Accepted Parameters

  • $format DateTime Format
  • $timezone String or DateTimeZone object (optional)

Twig template

{{ event.on | jdate('l, j. F Y') }}

Language File

SUNDAY		="neděle"
JUNE		="červen"

Result

neděle, 1. červen 2014

Application setup

See Joomla-Framework/Language package for instructions on how to setup the Language package in your application.

Running tests

$ composer install
$ phpunit

Licence

This extensions are released under the MIT License, except Date extension which is released under GPL2

统计信息

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

GitHub 信息

  • Stars: 5
  • Watchers: 3
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2014-03-17

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固