我開始創建自己的捆綁包並將它們上傳到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。
添加同捆也許一個assetic:傾倒?感謝,它似乎是工作的 – pbenard