2017 © Pedro Peláez
 

library twig-highlight

Twig extension to highlight content

image

magdkudama/twig-highlight

Twig extension to highlight content

  • Wednesday, November 12, 2014
  • by magdkudama
  • Repository
  • 1 Watchers
  • 1 Stars
  • 3 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

Twig highlight extension

Build Status, (*1)

Simple extension to highlight code (it could be done using a filter or a function, of course... but why not with a custom tag? :D)., (*2)

Installing

Add the dependency to the composer.json file:, (*3)

{
    "require": {
        "magdkudama/twig-highlight": "dev-master"
    }
}

A minimum working version:, (*4)

<?php

use MagdKudama\Highlight\Extension;
use MagdKudama\Highlight\Engine\PygmentsRenderer;

$twig = // Initialize Twig!

$twig->addExtension(new Extension(new PygmentsRenderer()));

Usage

{% highlight 'php' with { theme: 'vim' } ignore_errors %}
    <?php

    echo "Hello World!";

    for ($i = 0; $i < 10; $i++) {
        echo $i;
    }
{% endhighlight %}

{% highlight 'php' with { theme: 'vim' } %}
    ... code here ...
{% endhighlight %}

{% highlight 'php' %}
    ... code here ...
{% endhighlight %}

{% highlight 'php' ignore_errors %}
    ... code here ...
{% endhighlight %}

The language (php in this case) is required, but the parameters (with {} and ignore_errors are optional)., (*5)

If you don't want to use Pygments, you can create your own engine by implementing the MagdKudama\Highlight\Engine interface., (*6)

TODO

  • Support... Maybe Geshi?
  • Default content when there's an error... Maybe!

License

Twig highlight extension is licensed under the MIT license., (*7)

Contributors

  • Magd Kudama [magdkudama]

The Versions

12/11 2014

dev-master

9999999-dev

Twig extension to highlight content

  Sources   Download

MIT

The Requires

 

The Development Requires

twig php highlight