Skip to content

Commit

Permalink
feat(extensions): add Math extension
Browse files Browse the repository at this point in the history
  • Loading branch information
Awilum committed Jul 11, 2022
1 parent a329abd commit 5fed0bf
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 0 deletions.
1 change: 1 addition & 0 deletions settings.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ parsers:
enabled: true
path: "project/plugins/twig/src/twig/core/Parsers/Shortcodes/TwigShortcode.php"
extensions:
- Math
- I18n
- Filesystem
- Csrf
Expand Down
38 changes: 38 additions & 0 deletions src/twig/core/Extensions/MathTwigExtension.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?php

declare(strict_types=1);

/**
* Flextype - Hybrid Content Management System with the freedom of a headless CMS
* and with the full functionality of a traditional CMS!
*
* Copyright (c) Sergey Romanenko (https://awilum.github.io)
*
* Licensed under The MIT License.
*
* For full copyright and license information, please see the LICENSE
* Redistributions of files must retain the above copyright notice.
*/

namespace Flextype\Plugin\Twig\Extension;

use Twig\Extension\AbstractExtension;
use Twig\TwigFunction;

class MathTwigExtension extends AbstractExtension
{
/**
* Callback for twig.
*
* @return array
*/
public function getFunctions() : array
{
return [
new TwigFunction('ceil', '\ceil'),
new TwigFunction('floor', '\floor'),
new TwigFunction('min', '\min'),
new TwigFunction('max', '\max')
];
}
}

0 comments on commit 5fed0bf

Please sign in to comment.