xutl / yii2-highlightjs-widget
Yii 框架的 highlightjs 扩展
2.0.1
2017-06-06 01:48 UTC
Requires
- php: >=5.4.0
- yiisoft/yii2: *
This package is auto-updated.
Last update: 2024-09-11 02:43:06 UTC
README
安装
安装此扩展的首选方式是通过 composer。
可以运行
php composer.phar require --prefer-dist xutl/yii2-highlightjs-asset
或者在你的 composer.json
文件的 require 部分添加
"xutl/yii2-highlightjs-asset": "~1.0.0"
使用
use xutl\highlightjs\HighlightJsAsset; HighlightJsAsset::register($this,'php'); $this->registerJs('hljs.initHighlightingOnLoad();');
use xutl\highlightjs\HighlightJs; HighlightJs::begin([ 'format'=>$model->format ]); echo Html::encode($model->content); ?> HighlightJs::end()