hearsayit / HearsayRequireJSBundle

RequireJS integration for Symfony2.
130 stars 55 forks source link

Twig Exception about Template name... #61

Open rayrigam opened 10 years ago

rayrigam commented 10 years ago

As previously indicated in my comments to commit https://github.com/hearsayit/HearsayRequireJSBundle/commit/9293c46b35bdc652effb1928de82543e3de4e097, I get the following exception when updating to that commit or beyond:

CRITICAL - Uncaught PHP Exception Twig_Error_Runtime: "An exception has been thrown during the rendering of a template ("Template name "/cdnjs.cloudflare.com/ajax/libs/require.js/2.1.8/require.min.js" is not valid (format is "bundle:section:template.format.engine").") in "HearsayRequireJSBundle::initialize.html.twig"

Apparently, this error has to do with the format of the default "require_js_src" parameter. Should I not use the default?

I have tried changing my configuration but the error persists. Here is my configuration (which should be pretty standard):

# app/config/config.yml
hearsay_require_js:
    base_dir: '%kernel.root_dir%/../src/Acme/DemoBundle/Resources/public/js'
    paths:
        jquery:
            location: [//ajax.googleapis.com/ajax/libs/jquery/2.0.0/jquery.min, %kernel.root_dir%/../src/Acme/DemoBundle/Resources/public/js/libs/jquery/2.0.0/jquery.min]
            external: true
        underscore:
            location: [//cdnjs.cloudflare.com/ajax/libs/underscore.js/1.4.4/underscore-min, %kernel.root_dir%/../src/Acme/DemoBundle/Resources/public/js/libs/underscore/1.4.4/underscore-min]
            external: true
        backbone:
            location: [//cdnjs.cloudflare.com/ajax/libs/backbone.js/1.0.0/backbone-min, %kernel.root_dir%/../src/Acme/DemoBundle/Resources/public/js/libs/backbone/1.0.0/backbone-min]
            external: true
    shim:
        backbone:
            deps: [underscore, jquery]
            exports: Backbone
        underscore:
            exports: _
    optimizer:
        path: %kernel.root_dir%/../src/Acme/DemoBundle/Resources/public/js/libs/require/2.1.8/r.js
        hide_unoptimized_assets: false
        options:
            name: app

twig:
    debug:            %kernel.debug%
    strict_variables: %kernel.debug%

assetic:
    debug:          %kernel.debug%
    use_controller: false
    bundles:        [DemoBundle]
    #java: /usr/bin/java
    filters:
        compass: ~
        cssrewrite: ~

Also, I'm using RequireJS as an Assetic filter in my template as follows:

{% block scripts %}
    {% javascripts filter='?requirejs' '@AcmeDemoBundle/Resources/public/js/app.js' %}
        {{ require_js_initialize({ 'main': asset_url })}}
    {% endjavascripts %}
{% endblock %}

And my main "app.js" file that should be loaded:

// Filename src/Acme/DemoBundle/Resources/public/js/app.js

"use strict";

require([
  'router',
  'modules/main',
], function(Router, Main) {
  new Router;
  new Main;
});