2013-05-06 23 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