Skip to content

Commit

Permalink
Twig 1.0.1
Browse files Browse the repository at this point in the history
  • Loading branch information
Awilum committed May 7, 2020
1 parent 0ba38af commit 6cfb996
Show file tree
Hide file tree
Showing 5 changed files with 66 additions and 3 deletions.
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
<a name="1.0.1"></a>
# [1.0.1](https://github.com/flextype-plugins/twig/compare/v1.0.0...v1.0.1) (2020-05-07)

### Features
* **core:** add new Shortcode Twig filter

```
{{ entry.content|shortcode }}
```
<a name="1.0.0"></a>
# [1.0.0](https://github.com/flextype-plugins/twig) (2020-04-28)
* Initial Release
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ The following dependencies need to be installed for Twig Plugin.

| Item | Version | Download |
|---|---|---|
| [flextype](https://github.com/flextype/flextype) | 0.9.8 | [download](https://github.com/flextype/flextype/releases/download/v0.9.8/flextype-0.9.8.zip) |
| [flextype](https://github.com/flextype/flextype) | 0.9.8 | [download](https://github.com/flextype/flextype/releases) |

## Installation

Expand Down
2 changes: 1 addition & 1 deletion plugin.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: Twig
version: 1.0.0
version: 1.0.1
description: Twig plugin to present Twig template engine for Flextype.
icon: fas fa-palette
author:
Expand Down
2 changes: 1 addition & 1 deletion settings.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ auto_reload: true
cache: true
debug: false
charset: "UTF-8"
extensions: ['Cache', 'Entries', 'Emitter', 'I18n', 'Json', 'Yaml', 'Parser', 'Serializer', 'Markdown', 'Filesystem', 'Csrf', 'GlobalVars', 'Url', 'Registry']
extensions: ['Cache', 'Entries', 'Emitter', 'I18n', 'Json', 'Yaml', 'Parser', 'Serializer', 'Markdown', 'Filesystem', 'Csrf', 'GlobalVars', 'Url', 'Registry', 'Shortcodes']

# Twig plugin priority
priority: 100
53 changes: 53 additions & 0 deletions twig/ShortcodesTwigExtension.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
<?php

declare(strict_types=1);

/**
* Flextype (http://flextype.org)
* Founded by Sergey Romanenko and maintained by Flextype Community.
*/

namespace Flextype;

use Twig_Extension;
use Twig_SimpleFilter;

class ShortcodesTwigExtension extends Twig_Extension
{
/**
* Flextype Dependency Container
*/
private $flextype;

/**
* Constructor
*/
public function __construct($flextype)
{
$this->flextype = $flextype;
}

/**
* Returns a list of filters to add to the existing list.
*
* @return array
*/
public function getFilters() : array
{
return [
new Twig_SimpleFilter('shortcode', [$this, 'shortcode']),
];
}

/**
* Shorcode process
*/
public function shortcode($value) : string
{
if ($value !== null) {
return $this->flextype->shortcodes->process($value);
}

return '';
}
}

0 comments on commit 6cfb996

Please sign in to comment.