Skip to content
This repository has been archived by the owner on Feb 7, 2023. It is now read-only.

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
dmolsen committed May 5, 2016
0 parents commit ce7cef0
Show file tree
Hide file tree
Showing 3 changed files with 93 additions and 0 deletions.
20 changes: 20 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
The MIT License (MIT)

Copyright (c) 2016 Dave Olsen, http://dmolsen.com

Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
30 changes: 30 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
"name": "pattern-lab/plugin-twig-extensions",
"description": "Twig Extensions for the PHP version of Pattern Lab",
"keywords": ["twig", "pattern lab"],
"homepage": "http://patternlab.io",
"license": "MIT",
"type": "patternlab-plugin",
"authors": [
{
"name": "Dave Olsen",
"email": "dmolsen@gmail.com",
"homepage": "http://dmolsen.com",
"role": "Lead Developer"
}
],
"support": {
"issues": "https://github.com/pattern-lab/mustachehelper-php-verbatim/issues",
"wiki": "http://patternlab.io/docs/",
"source": "https://github.com/pattern-lab/mustachehelper-php-verbatim/releases"
},
"autoload": {
"psr-0": {
"PatternLab\\TwigExtensions": "src/"
}
},
"require": {
"php": ">=5.3.6",
"twig/extensions": "~1.3"
}
}
43 changes: 43 additions & 0 deletions src/PatternLab/TwigExtensions/PatternLabListener.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<?php

/*!
* Twig Extensions Listener Class
*
* Copyright (c) 2016 Dave Olsen, http://dmolsen.com
* Licensed under the MIT license
*
* Adds Twig Extensions support to the Twig Pattern Engine
*
*/

namespace PatternLab\TwigExtensions;

use \PatternLab\PatternEngine\Twig\TwigUtil;

class PatternLabListener extends \PatternLab\Listener {

/**
* Add the listeners for this plug-in
*/
public function __construct() {

$this->addListener("twigPatternLoader.customize","addExtensions");

}

/**
* Add the extensions to the appropriate instance
*/
public function addExtensions() {

$instance = TwigUtil::getInstance();
$instance->addExtension(new \Twig_Extensions_Extension_Text());
$instance->addExtension(new \Twig_Extensions_Extension_I18n());
$instance->addExtension(new \Twig_Extensions_Extension_Intl());
$instance->addExtension(new \Twig_Extensions_Extension_Array());
$instance->addExtension(new \Twig_Extensions_Extension_Date());
TwigUtil::setInstance($instance);

}

}

0 comments on commit ce7cef0

Please sign in to comment.