hearsayit / HearsayRequireJSBundle

RequireJS integration for Symfony2.
130 stars 55 forks source link

require_js Twig global no longer created #49

Closed bobwallis closed 10 years ago

bobwallis commented 10 years ago

I'm getting the error message Variable "hearsay_require_js" does not exist when following the instructions:

If you need to do anything fancy with the configuration, you can do so manually by modifying the default configuration, and suppressing config output when initializing RequireJS

A trip into ./Twig/Extension/RequireJSExtension.php shows that the reason for that error is that unlike in the 1.0.0 branch the Twig global is now never actually created.

Adding:

    public function getGlobals()
    {
        return array(
            'require_js' => array(
                'config' => $this->getHelper()->config(),
                'src' => $this->getHelper()->src(),
            ),
        );
    }

to ./Twig/Extension/RequireJSExtension.php.

and:

    public function config()
    {

        return $this->configurationBuilder->getConfiguration();
    }

to ./Templating/Helper/RequireJSHelper.php

adds back in the functionality from the 1.0 branch.