This widget enable syntax highlighting of code snippets in your web application using Google Code Prettify.
Requirements ¶
Yii 1.1.6 or above...(tested with 1.1.10)
Usage ¶
- install and explore the demo application
- or extract the widget file under .../protected/extensions
- put in a view a code block like the following...
Sample : HTML code ¶
<?php $this->beginWidget('ext.prettify.JPrettify');?>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Code Sample</title>
</head>
<body>
<b>Hello World!</b>
</body>
</html>
<?php $this->endWidget();?>
Sample : PHP code from file ¶
<?php
$this->widget('ext.prettify.JPrettify',array(
'lang'=>"php5",
'showLineNumbers'=>true,
'pathAlias'=>"system.base",
'fileName'=>"CComponent.php",
'htmlOptions'=>array('style'=>'max-height: 340px; overflow-y: scroll;')
));
?>
Sample : HTML5 code from any website ¶
<?php
$this->widget('ext.prettify.JPrettify',array(
'fileName'=>"http://www.yiiframework.com/",
'htmlOptions'=>array('style'=>'max-height: 600px; overflow-y: scroll;'))
);
?>
Change log ¶
Version 1.0 ¶
- initial release
Version 1.1 ¶
- code cleaning
- bug fix
- better support for highlighting of PHP5 keywords
If you have any questions, please ask in the forum instead.
Signup or Login in order to comment.