Jade Gii Generator for Yii2
, (*1)
Works well with Yii2 Tale Jade, the Tale Jade for PHP integration for the Yii2 framework., (*2)
Installation with Composer
Installation is recommended to be done via composer by running:, (*3)
composer require jacmoe/yii2-gii-jade "*"
Configuration
Add it to your configuration (frontend/config/main-local.php and/or backend/config/main-local.php for the advanced template)., (*4)
Add the generator
if (!YII_ENV_TEST) {
// configuration adjustments for 'dev' environment
$config['bootstrap'][] = 'debug';
$config['modules']['debug'] = 'yii\debug\Module';
$config['bootstrap'][] = 'gii';
$config['modules']['gii'] = [
'class' => 'yii\gii\Module',
'allowedIPs' => ['127.0.0.1', '::1', '192.168.0.*', '192.168.178.20'],
'generators' => [
'jadecrud' => [
'class' => 'jacmoe\giijade\crud\Generator',
'templates' => [
'myCrud' => '@jacmoe/giijade/crud/default',
]
]
],
];
}
Set defaultExtension
'components' => [
...
],
'view' => [
'defaultExtension' => 'jade',
...
Alternatively, if you don't want to set the default extension for the views, then you need to explicitly set the extension in your views/controllers., (*5)
For instance:, (*6)
public function actionAbout()
{
return $this->render('about.jade');
}
...
$this->render('_form.jade', ['model' => $model,])
Known Bugs
When the i18n option is turned on for the generator, there will be an error in update.jade that looks like this:, (*7)
-$view->title = Yii::t('app', 'Update {modelClass}: ', [
'modelClass' => 'User',
]) . ' ' . $model->id
You need to remove the line breaks, like this:, (*8)
-$view->title = Yii::t('app', 'Update {modelClass}: ', ['modelClass' => 'User',]) . ' ' . $model->id
License
The Jade Gii Generator for Yii2 is released under the MIT license., (*9)