How to add your tag to the twig?

Good time of day.

How to add your tag to the twig?
There is a standard {{ - }} and {% - %}, is it possible to add your own, like {dev - dev}?

Or how to do the following:
There is a tag, for example - {{ dev.XXX }} - instead of XXX - specific methods of php class which return some data.
Add each separately is possible, but a bastard :)
Is there any way automatic? All class methods are available for such treatment
March 23rd 20 at 18:49
1 answer
March 23rd 20 at 18:51
https://symfony.com/doc/current/templating/global_...

it is for the Symphony, but the point's the same

//added:
Wrote from memory, maybe not quite so will

TwigGlobals.php
namespace App\Service;

class TwigGlobals
{
 public function getInfo()
{
 return [
 'var_one' => 1,
 'var_two' => 2,
];
}
}


test.html.twig
{% block a %}

 {{ getMainInfo().var_one }}

{% endblock %}
But where does the actual variables?
I'm talking about functions say - dean_Fra commented on March 23rd 20 at 18:54
@dean_Fra, added an example that there is not necessarily a variable - graciela.Bei commented on March 23rd 20 at 18:57

Find more questions by tags Twig