twig_js与Symfony 2.3捆绑在一起

twig_js bundle with Symfony 2.3

本文关键字:在一起 Symfony js twig      更新时间:2023-09-26

我安装了twig_js捆绑包:https://github.com/schmittjoh/JMSTwigJsBundle/blob/master/Resources/doc/index.rst

我使用包装师:https://packagist.org/packages/jms/twig-js-bundle

我的布局中有以下代码:

{% javascripts 
    '@AcmeFooBundle/Resources/public/js/ajax.js' 
filter='twig_js, ?yui_js' %}
    <script type="text/javascript" src="{{ asset_url }}"></script>
{% endjavascripts %}

但是当我尝试使用此命令行转储我的资产时:PHP 应用程序/控制台资产:转储

我有这个错误:

[InvalidArgumentException] 模板名称"Resources/public/js/ajax.js"无效(格式为"bundle :section:template.format.engine")。

这里是 app/config.yml 文件的资产配置:

# Assetic Configuration
assetic:
debug:          "%kernel.debug%"
use_controller: false
bundles:
    - AcmeFooBundle
    - JMSTwigJsBundle
filters:
    yui_js:
        jar: "%kernel.root_dir%/Resources/java/yuicompressor.jar"
    twig_js:
        resource: "%kernel.root_dir%/../vendor/jms/twig-js-bundle/JMS/TwigJsBundle/Resources/config/services.xml"
        apply_to: "'.twig$"
    cssrewrite: ~
    #java: /usr/bin/java
    #closure:
    #    jar: "%kernel.root_dir%/Resources/java/compiler.jar"
    #yui_css:
    #    jar: "%kernel.root_dir%/Resources/java/yuicompressor-2.4.7.jar"

有人对此有想法吗?提前谢谢你。

查看此链接...似乎是一个可能的解决方法。

http://symfony.com/doc/current/cookbook/assetic/asset_management.html