firefly-iii/config/twigbridge.php

302 lines
10 KiB
PHP
Raw Normal View History

2015-05-25 00:03:26 -05:00
<?php
2021-01-29 11:50:35 -06:00
/*
* twigbridge.php
* Copyright (c) 2021 james@firefly-iii.org
*
* This file is part of Firefly III (https://github.com/firefly-iii).
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
2020-03-17 11:06:30 -05:00
declare(strict_types=1);
/**
2019-12-28 02:44:56 -06:00
* This file is part of the TwigBridge package.
*
2019-12-28 02:44:56 -06:00
* @copyright Robert Crowe <hello@vivalacrowe.com>
*
2019-12-28 02:44:56 -06:00
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
2019-12-28 02:44:56 -06:00
use FireflyIII\Support\Twig\AmountFormat;
use FireflyIII\Support\Twig\General;
use FireflyIII\Support\Twig\Rule;
use FireflyIII\Support\Twig\TransactionGroupTwig;
use FireflyIII\Support\Twig\Translation;
2019-03-02 13:14:45 -06:00
use TwigBridge\Extension\Laravel\Dump;
use TwigBridge\Extension\Laravel\Input;
2019-12-28 02:44:56 -06:00
use TwigBridge\Extension\Laravel\Model;
use TwigBridge\Extension\Laravel\Str;
use TwigBridge\Extension\Laravel\Translator;
use TwigBridge\Extension\Laravel\Url;
use TwigBridge\Extension\Loader\Facades;
2018-05-11 03:08:34 -05:00
use TwigBridge\Extension\Loader\Filters;
use TwigBridge\Extension\Loader\Functions;
2019-03-02 13:14:45 -06:00
2016-09-15 23:19:40 -05:00
/**
* Configuration options for Twig.
*/
2015-05-25 00:03:26 -05:00
return [
2016-08-26 01:21:31 -05:00
'twig' => [
2015-05-25 00:03:26 -05:00
/*
|--------------------------------------------------------------------------
| Extension
|--------------------------------------------------------------------------
|
| File extension for Twig view files.
|
*/
2019-12-28 02:59:41 -06:00
'extension' => 'twig',
2015-05-25 00:03:26 -05:00
/*
|--------------------------------------------------------------------------
| Accepts all Twig environment configuration options
|--------------------------------------------------------------------------
|
| http://twig.sensiolabs.org/doc/api.html#environment-options
|
*/
'environment' => [
// When set to true, the generated templates have a __toString() method
// that you can use to display the generated nodes.
// default: false
2019-12-28 02:59:41 -06:00
'debug' => env('APP_DEBUG', false),
2015-05-25 00:03:26 -05:00
// The charset used by the templates.
2019-03-02 13:14:45 -06:00
// default: utf-8
2019-12-28 02:59:41 -06:00
'charset' => 'utf-8',
2015-05-25 00:03:26 -05:00
// The base template class to use for generated templates.
// default: TwigBridge\Twig\Template
2019-12-28 02:44:56 -06:00
'base_template_class' => 'TwigBridge\Twig\Template',
2015-05-25 00:03:26 -05:00
// An absolute path where to store the compiled templates, or false to disable caching. If null
// then the cache file path is used.
// default: cache file storage path
2019-12-28 02:59:41 -06:00
'cache' => null,
2015-05-25 00:03:26 -05:00
// When developing with Twig, it's useful to recompile the template
// whenever the source code changes. If you don't provide a value
// for the auto_reload option, it will be determined automatically based on the debug value.
2019-12-28 02:59:41 -06:00
'auto_reload' => true,
2015-05-25 00:03:26 -05:00
// If set to false, Twig will silently ignore invalid variables
// (variables and or attributes/methods that do not exist) and
// replace them with a null value. When set to true, Twig throws an exception instead.
// default: false
2019-12-28 02:59:41 -06:00
'strict_variables' => false,
2015-05-25 00:03:26 -05:00
// If set to true, auto-escaping will be enabled by default for all templates.
2016-09-15 23:19:40 -05:00
// default: 'html'
2019-12-28 02:59:41 -06:00
'autoescape' => 'html',
2015-05-25 00:03:26 -05:00
// A flag that indicates which optimizations to apply
// (default to -1 -- all optimizations are enabled; set it to 0 to disable)
2019-12-28 02:59:41 -06:00
'optimizations' => -1,
2015-05-25 00:03:26 -05:00
],
/*
|--------------------------------------------------------------------------
| Global variables
|--------------------------------------------------------------------------
|
| These will always be passed in and can be accessed as Twig variables.
| NOTE: these will be overwritten if you pass data into the view with the same key.
|
*/
2019-12-28 02:59:41 -06:00
'globals' => [],
2015-05-25 00:03:26 -05:00
],
'extensions' => [
/*
|--------------------------------------------------------------------------
| Extensions
|--------------------------------------------------------------------------
|
| Enabled extensions.
|
2019-03-02 13:14:45 -06:00
| `Twig\Extension\DebugExtension` is enabled automatically if twig.debug is TRUE.
2015-05-25 00:03:26 -05:00
|
*/
2020-03-20 11:31:54 -05:00
'enabled' => [
2018-04-02 07:43:06 -05:00
Facades::class,
Filters::class,
Functions::class,
2019-12-28 02:44:56 -06:00
\TwigBridge\Extension\Laravel\Auth::class,
\TwigBridge\Extension\Laravel\Config::class,
2018-04-02 07:43:06 -05:00
Dump::class,
Input::class,
2019-12-28 02:44:56 -06:00
\TwigBridge\Extension\Laravel\Session::class,
2018-04-02 07:43:06 -05:00
Str::class,
Translator::class,
Url::class,
2019-12-28 02:44:56 -06:00
Model::class,
2016-09-15 23:19:40 -05:00
// 'TwigBridge\Extension\Laravel\Gate',
2015-05-25 00:03:26 -05:00
2016-09-15 23:19:40 -05:00
// 'TwigBridge\Extension\Laravel\Form',
2015-05-25 00:03:26 -05:00
// 'TwigBridge\Extension\Laravel\Html',
// 'TwigBridge\Extension\Laravel\Legacy\Facades',
2019-12-28 02:44:56 -06:00
AmountFormat::class,
General::class,
Rule::class,
TransactionGroupTwig::class,
Translation::class,
2015-05-25 00:03:26 -05:00
],
/*
|--------------------------------------------------------------------------
| Facades
|--------------------------------------------------------------------------
|
| Available facades. Access like `{{ Config.get('foo.bar') }}`.
|
| Each facade can take an optional array of options. To mark the whole facade
| as safe you can set the option `'is_safe' => true`. Setting the facade as
| safe means that any HTML returned will not be escaped.
|
| It is advisable to not set the whole facade as safe and instead mark the
| each appropriate method as safe for security reasons. You can do that with
| the following syntax:
|
| <code>
| 'Form' => [
| 'is_safe' => [
| 'open'
| ]
| ]
| </code>
|
| The values of the `is_safe` array must match the called method on the facade
| in order to be marked as safe.
|
*/
'facades' => [
2019-08-10 09:50:37 -05:00
'Breadcrumbs' => [
2015-05-25 00:03:26 -05:00
'is_safe' => [
'render',
2016-08-26 01:21:31 -05:00
],
2015-05-25 00:03:26 -05:00
],
'Session',
'Route',
'Auth',
'Lang',
'Preferences',
2015-05-25 00:03:26 -05:00
'URL',
2017-08-30 00:40:39 -05:00
'Steam',
2015-05-25 00:03:26 -05:00
'Config',
'Request',
2020-03-17 11:06:30 -05:00
'Form' => ['is_safe' => ['input', 'select', 'checkbox', 'model', 'open', 'radio', 'textarea', 'file']],
2019-08-10 09:50:37 -05:00
'ExpandedForm' => [
'is_safe' => [
'date', 'text', 'select', 'balance', 'optionsList', 'checkbox', 'amount', 'tags', 'integer', 'textarea', 'location', 'file', 'staticText',
2020-06-07 09:38:15 -05:00
'password', 'nonSelectableAmount', 'number', 'amountNoCurrency', 'percentage','objectGroup'
2019-06-29 12:47:40 -05:00
],
],
2019-08-10 09:50:37 -05:00
'AccountForm' => [
'is_safe' => [
2020-10-31 02:00:44 -05:00
'activeWithdrawalDestinations', 'activeDepositDestinations', 'assetAccountCheckList', 'assetAccountList', 'longAccountList',
],
2015-05-25 00:03:26 -05:00
],
2019-08-10 09:50:37 -05:00
'CurrencyForm' => [
'is_safe' => [
'currencyList', 'currencyListEmpty', 'balanceAll',
],
],
2020-03-17 11:06:30 -05:00
'PiggyBankForm' => [
'is_safe' => [
'piggyBankList',
2019-08-10 09:50:37 -05:00
],
2020-03-17 11:06:30 -05:00
],
2019-08-10 09:50:37 -05:00
'RuleForm' => [
'is_safe' => [
'ruleGroupList', 'ruleGroupListWithEmpty',
],
],
2015-05-25 00:03:26 -05:00
],
/*
|--------------------------------------------------------------------------
| Functions
|--------------------------------------------------------------------------
|
| Available functions. Access like `{{ secure_url(...) }}`.
|
| Each function can take an optional array of options. These options are
2019-03-02 13:14:45 -06:00
| passed directly to `Twig\TwigFunction`.
2015-05-25 00:03:26 -05:00
|
| So for example, to mark a function as safe you can do the following:
|
| <code>
| 'link_to' => [
| 'is_safe' => ['html']
| ]
| </code>
|
| The options array also takes a `callback` that allows you to name the
| function differently in your Twig templates than what it's actually called.
|
| <code>
| 'link' => [
| 'callback' => 'link_to'
| ]
| </code>
|
*/
'functions' => [
'elixir',
'head',
'last',
2019-03-02 13:14:45 -06:00
'mix',
2015-05-25 00:03:26 -05:00
],
/*
|--------------------------------------------------------------------------
| Filters
|--------------------------------------------------------------------------
|
| Available filters. Access like `{{ variable|filter }}`.
|
| Each filter can take an optional array of options. These options are
2019-03-02 13:14:45 -06:00
| passed directly to `Twig\TwigFilter`.
2015-05-25 00:03:26 -05:00
|
| So for example, to mark a filter as safe you can do the following:
|
| <code>
| 'studly_case' => [
| 'is_safe' => ['html']
| ]
| </code>
|
| The options array also takes a `callback` that allows you to name the
| filter differently in your Twig templates than what is actually called.
|
| <code>
| 'snake' => [
| 'callback' => 'snake_case'
| ]
| </code>
|
*/
2020-03-20 11:31:54 -05:00
'filters' => [
2016-09-15 23:19:40 -05:00
'get' => 'data_get',
],
2016-08-26 01:21:31 -05:00
],
2015-05-25 15:04:24 -05:00
];