Advertisement
Guest User

requirejs.html.twig

a guest
Aug 7th, 2014
278
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <script src="{{ asset(assetsPath~'/vendor/requirejs/require.js') }}"></script>
  2. <script>
  3.  
  4.     // let the baseUrl be dynamic so we can use the compiled assets when needed
  5.     requirejs.config({
  6.         baseUrl: '{{ app.request.basePath }}/{{ assetsPath }}/js',
  7.         paths: {
  8.             routes: '{{ path('fos_js_routing_js', {"callback": "fos.Router.setData"}) }}'
  9.         }
  10.         {#,paths: {#}
  11.         {#fos_routing: '{{ asset('bundles/fosjsrouting/js/router.js') }}',#}
  12.         {#fos_routing_data: '{{ path('fos_js_routing_js', {'_format': 'json', 'noext': 1}) }}'#}
  13.         {#},#}
  14.         {#shim: {#}
  15.         {#fos_routing: { exports: 'Routing' }#}
  16.         {#}#}
  17.     });
  18.  
  19.     /**
  20.      * The heart of our require.js setup!
  21.      *
  22.      *   1) Require the common.js file to get all the paths and shim setup
  23.      *   2) Once that file is downloaded, download and execute app/default.js
  24.      *      (a global module, executed on every page) and execute whatever
  25.      *      page-specific app we have (e.g. app/homepage). This will do
  26.      *      whatever craziness we want.
  27.      */
  28.     require(['common'], function (common) {
  29.         {% if module %}
  30.         require(['app/default', '{{ module }}']);
  31.         {% else %}
  32.         require(['app/default']);
  33.         {% endif %}
  34.     });
  35. </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement