mirror of
				https://github.com/yiisoft/yii2.git
				synced 2025-11-04 06:37:55 +08:00 
			
		
		
		
	translated template-engines
This commit is contained in:
		@ -1,11 +1,9 @@
 | 
			
		||||
Using template engines
 | 
			
		||||
使用模板引擎
 | 
			
		||||
======================
 | 
			
		||||
 | 
			
		||||
By default, Yii uses PHP as its template language, but you can configure Yii to support other rendering engines, such as
 | 
			
		||||
[Twig](http://twig.sensiolabs.org/) or [Smarty](http://www.smarty.net/) available as extensions.
 | 
			
		||||
默认情况下,Yii 使用 PHP 作为其默认的模板引擎语言,但是,你可以配置 Yii 以扩展的方式支持其他的渲染引擎,比如 [Twig](http://twig.sensiolabs.org/) 或 [Smarty](http://www.smarty.net/)等。
 | 
			
		||||
 | 
			
		||||
The `view` component is responsible for rendering views. You can add a custom template engine by reconfiguring this
 | 
			
		||||
component's behavior:
 | 
			
		||||
组件 `view` 就是用于渲染视图的。你可以重新配置这个组件的行为以增加一个自定义的模板引擎。
 | 
			
		||||
 | 
			
		||||
```php
 | 
			
		||||
[
 | 
			
		||||
@ -34,16 +32,16 @@ component's behavior:
 | 
			
		||||
]
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
In the code above, both Smarty and Twig are configured to be useable by the view files. But in order to get these extensions into your project, you need to also modify
 | 
			
		||||
your `composer.json` file to include them, too:
 | 
			
		||||
在上述的代码中, Smarty 和 Twig 都被配置以让视图文件使用。但是,为了让扩展安装到项目中,你同样需要修改你的 `composer.json` 文件,如下:
 | 
			
		||||
 | 
			
		||||
```
 | 
			
		||||
"yiisoft/yii2-smarty": "*",
 | 
			
		||||
"yiisoft/yii2-twig": "*",
 | 
			
		||||
```
 | 
			
		||||
That code would be added to the `require` section of `composer.json`. After making that change and saving the file, you can install the extensions by running `composer update --prefer-dist` in the command-line.
 | 
			
		||||
 | 
			
		||||
For details about using concrete template engine please refer to its documentation:
 | 
			
		||||
上述代码需要增加到 `composer.json` 的 `require` 节中。在做了上述修改,并保存后,你可以运行 `composer update --prefer-dist` 命令来安装扩展。
 | 
			
		||||
 | 
			
		||||
对于特定模板引擎的使用详细,请参考其文档:
 | 
			
		||||
 | 
			
		||||
- [Twig guide](https://github.com/yiisoft/yii2-twig/tree/master/docs/guide)
 | 
			
		||||
- [Smarty guide](https://github.com/yiisoft/yii2-smarty/tree/master/docs/guide)
 | 
			
		||||
		Reference in New Issue
	
	Block a user