Twig Editor does not respect Twig Extensions

PHP Tools [?] extends Visual Studio with set of advanced features to work more efficiently with PHP code.

Twig Editor does not respect Twig Extensions

Postby EraYaN » May 5th, 2018, 5:25 am

I setup my Twig like this currently. (Using Slim v3)

Code: Select all
$container['view'] = function ($c) {
    $view = new \Slim\Views\Twig('twig-templates', [
        'cache' => $c['settings']['caching'],
        'debug' => $c['settings']['debug']
    ]);
    // Instantiate and add Slim specific extension
    $view->addExtension(new \Slim\Views\TwigExtension($c['router'], $c['request']->getUri()));
    $view->addExtension(new Twig_Extensions_Extension_I18n());
    if($c['settings']['debug'])
        $view->addExtension(new Twig_Extension_Debug());
    $view->addExtension(new SlugifyExtension(Slugify::create()));
    $twig_env = $view->getEnvironment();
    $twig_env->addGlobal('session', $_SESSION);
    global $cfg;
    $twig_env->addGlobal('cfg', $cfg);
    global $data;
    $twig_env->addGlobal('data', $data);

    return $view;
};


Now the SimpleFunctions provided by \Slim\Views\TwigExtension all get red squiqqly lines and the SplitView doesn't work at all.

It is a custom fork of the Twig-View componenet: https://github.com/EraYaN/Twig-View/blo ... ension.php the getFunctions function is correctly implemented.

And the second thing is the 'trans' tag only works in full tag format. Not in the
Code: Select all
{% trans 'Word' %}
syntax, that gives an unexpected token error in the editor. (But it does not happen across the board.)

Is there any way to make this work?
EraYaN
 
Posts: 9
Joined: June 5th, 2014, 11:06 am

Re: Twig Editor does not respect Twig Extensions

Postby Michal Brabec » May 9th, 2018, 12:47 pm

Hi EraYaN,
thank you for your feedback.
The extension functions from Slim are defined in a composer package, which is not currently analyzed by Twig.
We will add the analysis in the next update.

Symfony extensions for Twig are not yet supported.
We will add the support in the future, but we
Best regards,
Michal
Michal Brabec │ DEVSENSE s.r.o. │ @gMichalBrabecmichal.brabec@devsense.com
User avatar
Michal Brabec
 
Posts: 13
Joined: September 14th, 2016, 8:55 am


Return to PHP Tools

Who is online

Users browsing this forum: No registered users and 43 guests

cron

User Control Panel

Login

Who is online

In total there are 43 users online :: 0 registered, 0 hidden and 43 guests (based on users active over the past 5 minutes)
Most users ever online was 256 on March 28th, 2024, 9:42 am

Users browsing this forum: No registered users and 43 guests