Yii 1.1: jchili

Client-side syntax highlighting for source code listings
2 followers

This widget encapsulates the Chili-jQuery plugin (modified version 2.2 for jQuery 1.4.2) and can be used to decorate code listings in most of popular computer languages (C++, C#, CSS, Delphi, Java, JavaScript, LotusScript, MySQL, PHP, and XHTML).

Requirements

Yii 1.1.6 or above...

Usage

  • install and explore the demo application
  • or extract the widget file under .../protected/extensions
  • put in a view a code blocks like the following...

Sample : HTML code

<?php
$html = <<<CODE
<html>
  <head>
    <title>Code Sample</title>
  </head>
  <body>
    <b>Hello World!</b>
  </body>
</html>
CODE;
$this->widget('ext.jchili.JChiliHighlighter',array(
    'lang'=>"html",
    'code'=>$html,
    'showLineNumbers'=>false
));
?>

Sample : PHP code loaded from a file:

<?php
$this->widget('ext.jchili.JChiliHighlighter',array(
    'fileName'=>__FILE__,
));
?>

Sample : Highlight a Yii class file:

<?php
$this->widget('ext.jchili.JChiliHighlighter',array(
    'pathAlias'=>"system.base",
    'fileName'=>"CComponent.php",
    'firstLineNumber'=>1,
));
?>

Sample : Highlight HTML5 content from a website

<?php
$this->widget('ext.jchili.JChiliHighlighter',array(
    'lang'=>"html",
    'fileName'=>"http://www.99lime.com/elements/",
    'firstLineNumber'=>1,
));
?>

Change log

Version 1.0

  • initial release

Version 1.4

  • code cleaning
  • bug fix
  • changed CSS

Resources

JQuery Plugin

Alternate Yii extensions

Be the first person to leave a comment

Please to leave your comment.

Create extension