tomaj / nette-auto-variable-template

自动变量模板工厂

2.2.0 2021-11-12 09:15 UTC

This package is not auto-updated.

Last update: 2024-09-14 18:25:56 UTC


README

这是一个简单的库,可以在所有latte模板(也包括组件)中分配变量。当你需要始终在所有模板中使用的变量时非常有用。

安装

composer require "tomaj/nette-auto-variable-template"

用法

在 config.neon 中您需要设置工厂

latte.templateFactory: {autowired: no}
templateFactory:
	factory: Tomaj\Latte\AutoVariableTemplateFactory(@latte.templateFactory)
	setup:
		- registerVariable('variableName', @someValue)
		- registerVariable('otherVariable', 'something else')

在每一个模板中都会存在变量 {$variableName}{$otherVariable}