-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
66 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 ''; | ||
} | ||
} |