2016-01-22 68 views
0

我开始创建自己的捆绑包并将它们上传到github。Symfony:如何使用Assetic加载供应商的图像?

我刚刚创建了这一点:https://github.com/Ziiweb/FrontendBundle

捆里面,这里有个形象:https://github.com/Ziiweb/FrontendBundle/tree/master/Resources/public/images

而且我加载下面这样的形象在同捆的模板内,在同样的方式,因为它在docs说:

{% image '@ZiiwebFrontendBundle/Resources/public/images/ajax-loader.gif' %} 
<img class="loader" src="{{ asset_url }}" alt="Example" /> 
{% endimage %} 

问题:在另一个项目中安装包(作曲家)后,我得到的ER ROR试图请求模板,其中图像是在下面:模板 (“无法生成命名路由的URL‘_assetic_0b1c853_0’作为 这种途径的渲染过程中

异常被抛出呢不存在“)在 ZiiwebFrontendBundle:默认:contact.html.twig在管线15

我得到使用此代码相同的消息:

{% image 'bundles/ziiwebfrontend/images/ajax-loader.gif' %} 
    <img class="loader" src="{{ asset_url }}" alt="Example" /> 
    {% endimage %} 

是的,我已经使用assets:install安装了资产,因此我的图像位于web/bundles/ziiwebfrontend/images/ajax-loader.gif

注:我认为我有Assetic正确安装..我已经使用这些3 steps

+0

添加同捆也许一个assetic:倾倒?感谢,它似乎是工作的 – pbenard

回答

0

我想你错过了在config.yml

assetic: 
    debug:   %kernel.debug% 
    use_controller: false 
    bundles:  [YourBundleName] 
+0

。无论如何,添加该行后,你提到,然后我已经删除它,并继续工作..事件,如果我清除缓存。 O_O – ziiweb