Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix src() method in RequireJSHelper.php #71

Open
liviucmg opened this issue Apr 20, 2014 · 1 comment
Open

Fix src() method in RequireJSHelper.php #71

liviucmg opened this issue Apr 20, 2014 · 1 comment

Comments

@liviucmg
Copy link

Hi there,

I'm using PHP templates instead of Twig templates, and when initializing RequireJS using

/* @var Hearsay\RequireJSBundle\Templating\Helper\RequireJSHelper $requireJs */
$requireJs = $view['require_js'];
echo $requireJs->initialize();

I get the following error:

An exception has been thrown during the rendering of a template ("Template name "/media/Storage/backed-up-storage/work/picofnet/website/website/app/../src/Picof/BaseBundle/Resources/public/components/requirejs/requirejs" contains invalid characters.") in HearsayRequireJSBundle::initialize.html.twig at line 46.

Doesn't matter whether I use the default file

hearsay_require_js:
    require_js_src:      //cdnjs.cloudflare.com/ajax/libs/require.js/2.1.8/require.min.js

or a custom file

hearsay_require_js:
    require_js_src:      %kernel.root_dir%/../src/Picof/BaseBundle/Resources/public/components/requirejs/requirejs

The fix is easy. The RequireJSHelper::src() method should first check if the file is supported by the rendering engine, and only then check if it exists. Not the other way around like it is doing now.

I'm going to do a pull request, if that's alright.

Thanks!

@liviucmg
Copy link
Author

Actually it seems that the lines also need to be wrapped up in a try-catch block, because $this->engine->supports is throwing an InvalidArgumentException.

@liviucmg liviucmg changed the title RequireJSHelper.php engine support check Fix src() method in RequireJSHelper.php Apr 20, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant