clthck/cakephp-jade

CakePHP 3 的 Jade 模板引擎插件

安装次数: 9,333

依赖项: 1

建议者: 0

安全: 0

星标: 0

关注者: 3

分支: 0

类型:cakephp-plugin

v1.0.0 2017-02-23 06:42 UTC

This package is not auto-updated.

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


README

Build Status Latest Stable Version Total Downloads License

CakePHP 3 的 Jade 模板引擎插件

Tale Jade for PHP 支持。

安装

  1. 下载 Composer 或更新 composer self-update
  2. 运行 php composer.phar require clthck/cakephp-jade

如果全局安装了 Composer,运行

composer require clthck/cakephp-jade

引导

将以下内容添加到您的 config/bootstrap.php 中以加载插件。

Plugin::load('JadeView');

应用范围使用

将以下内容放置到您的 AppController.php 中以加载 JadeView 类。

public function initialize()
{
    parent::initialize();

    $this->viewBuilder()
        ->className('JadeView.Jade')
        ->options(['pretty' => false]);
}

如果我们需要为 JadeView 实例加载额外的辅助类,该怎么办?在这种情况下,我们可以使 AppView 类继承 JadeView 类

...
use JadeView\View\JadeView;
...
class AppView extends JadeView
{
	...
	public function initialize()
	{
	    $this->viewOptions([
	        'pretty' => true
	    ]);

	    parent::initialize();
	    
	    $this->loadHelper('Form', [
	        'templates' => 'form_template'
	    ]);
	}
}

在模板文件 (.ctp.jade) 中

使用 $view 而不是 $this

= $view->Flash->render()

CakePHP JavaScript 块的使用示例

- $view->Html->scriptStart(['block' => true])
|
	$(function() {
		// Your js code goes here..
	});

- $view->Html->scriptEnd()

如果您使用的是 Sublime Text 2/3,您需要安装 cakephp-jade-tmbundle 以正确地启用语法高亮。

语言语法参考

请访问 jade.talesoft.io 查看语法参考。