2013-05-06 25 views
0

我想爲Symfony2使用BoostrapBundle,但我卡住了。使用資產與BootstrapBundle

我試圖安裝資產和使用the tutorial資產,但我不知道如何使用它在一個樹枝文件。

我試着用:

{% javascripts '@BcBootstrapBundle' %} 
    <script type="text/javascript" src="{{ bootstrap_js }}"></script> 
{% endjavascripts %} 

但我得到的錯誤:

An exception has been thrown during the compilation of a template ("There is no "BcBootstrapBundle" asset.")

根據手冊:

When you have AsseticBundle installed BootstrapBundle will automatically configure the assets from Twitter Bootstrap for you. If you want to change the configuration you can do this by overwritting the Assetic configuration.

但也沒什麼可說的好語法使用上一個樹枝文件,即使在BootstrapDemoBundle(如果你看源代碼,你會看到一個use Assetic評論,但它沒有幫助)。

next section中,他們給出了一個應用示例,該應用示例應該使用bootstrap,但它看起來像缺少某些東西。

<!DOCTYPE html> 
<html> 
    <head> 
    <title>Bootstrap 101 Template</title> 
    <!-- Bootstrap --> 
    <link rel="stylesheet" href="{{ asset('css/bootstrap.css') }}"> 
    </head> 
    <body> 
    <h1>Hello, world!</h1> 
    <script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script> 
    <script>window.jQuery || document.write('<script src="{{ asset('js/jquery.js') }}"><\/script>')</script> 
    <script src="{{ asset('js/bootstrap.js') }}"></script> 
    </body> 
</html> 

他們用一個簡單的{{ asset('file') }},誰點web/目錄(但我從來沒有把任何文件存在,所以沒有assets:install)。

所以我的問題是:

How to use the preconfigured assets to create a bootstrapped view?

回答

1

你應該先使用assetic:dump拋售資產。這個命令將生成你需要的文件,然後你可以用asset(...)函數包含它們。

+0

這麼簡單,但只是不知道。謝謝!! – 2013-05-07 05:06:28