Skip to content

ifdattic/EPrism

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 

Repository files navigation

EPrism

EPrism is an extension for Yii framework. This extension is a wrapper for Prism by Lea Verou. Prism is a lightweight, extensible syntax highlighter, built with modern web standards in mind. This extension adds this great syntax highlighter using a widget() method.

Requirements

  • Yii 1.1 or above (tested on 1.1.14)

Installation

Composer

EPrism can be installed using a [Composer][composer-link].

Run the following command:

php composer.phar require ifdattic/eprism "dev-master"

or make sure you have the following code in composer.json file:

{
    "require": {
        "ifdattic/eprism": "dev-master"
    }
}

Manual installation

Download the latest version of extension, extract & place it in your project (extensions directory or any of your choice). Just make sure to adjust path for loading it.

Usage

Place the following code inside your view file:

<?php $this->widget('vendor.ifdattic.eprism.EPrism'); ?>

Default options can be changed by sending an array as a second parameter:

<?php $this->widget(
    'vendor.ifdattic.eprism.EPrism',
    [
        // Default values for properties
        'manualHighlight' => false,
        'scriptPosition' => null,
        'cssFile' => null,
        'scriptFile' => null,
    ]
); ?>

The explanation of options:

  • manualHighlight - The flag which disables automatic highlighting. If automatic highlighting is disabled, the highlight will have to be initiated manually using JavaScript.
  • scriptPosition - The position of the script (registerScriptFile() method documentation)
  • cssFile - The CSS file used by the highlighter. Available options:
    • false - CSS file won't be registered.
    • null - the default CSS file will be registered.
    • string - defined file will be registered.
  • scriptFile - The JS file used by the highlighter. Available options:
    • false - JS file won't be registered.
    • null - the default JS file will be registered.
    • string - defined file will be registered.

Here's the example using different values for extension:

<?php $this->widget(
    'vendor.ifdattic.eprism.EPrism',
    [
        // Only values you want to change need to be sent
        'manualHighlight' => true,
        'scriptPosition' => CClientScript::POS_END,
        'cssFile' => 'prism/prism.css',
        'scriptFile' => false,
    ]
); ?>

Resources

Notes

  • For convenience extension contains CSS & JS assets, but you will probably want to generate those files for your own needs and include them in the project.

About

Yii extension which adds Prism syntax highlighter

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published