geshi-twig-extension

Created: 2014-05-19 08:59
Updated: 2016-07-04 08:54
License: mit
php

README.md

Geshi Twig Extension

Build Status Latest Stable Version Total Downloads

NOTE : If you want to contribute don't hesitate, I'll review any PR.

Introduction

Twig extension for GeSHi - Generic Syntax Highlighter rendering.

Contributing

If you wish to contribute, please read both the CONTRIBUTING.md file.

Features

  • Filter support :

    • Highlight PHP : {{ "'<?php\necho \'test\';\n?>'|geshi('php') }}
    • Highlight PHP & use classes : {{ "'<?php\necho \'test\';\n?>'|geshi('php',true) }}
  • Tag support :

    • Highlight Javascript : {% geshi 'javascript' %}{"data": "test"}{% endgeshi %}
    • Highlight Javascript & display line numbers & use classes : {% geshi 'javascript' line_numbers use_classes %}{"data": "test"}{% endgeshi %}

Installation

Update your composer.json:

{
  "require": {
        "neilime/geshi-twig-extension": "1.*"
    }
}

Usage

Twig Extension

The Twig extension provides the geshi tag and filter support.

Assumed that you are using composer autoloading.

Adds the extension to the Twig environment:

$twig->addExtension(new \Twig\Extension\GeshiExtension());

Twig Token Parser

The Twig token parser provides the geshi tag :

$twig->addTokenParser(new \Twig\TokenParser\GeshiTokenParser());
Cookies help us deliver our services. By using our services, you agree to our use of cookies Learn more