clthck / cakephp-jade
CakePHP 3 的 Jade 模板引擎插件
v1.0.0
2017-02-23 06:42 UTC
Requires
- php: >=5.5.30
- cakephp/cakephp: ~3.0
- erusev/parsedown: *
- talesoft/tale-jade: *
README
CakePHP 3 的 Jade 模板引擎插件
由 Tale Jade for PHP 支持。
安装
- 下载 Composer 或更新
composer self-update
。 - 运行
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 查看语法参考。