简体   繁体   English

Symfony2加载徽标资产

[英]Symfony2 loading Assets for a Logo

I am trying to load a Logo in the base.html.twig . 我正在尝试在base.html.twig加载徽标。 Actually I think this should be extremely basic and easy. 实际上,我认为这应该是极其基本和容易的。 However I want this Asset not to lie in a Bundle but in app/Resource/ , because as far as I am concerned this should be the right place for App-Wide Resources. 但是,我希望此资产不位于捆绑包中,而应位于app/Resource/ ,因为就我而言,这应该是应用程序范围资源的正确位置。 However I can't load get it to load or even get copied to the web folder. 但是,我无法加载,无法加载甚至复制到Web文件夹。 Am I doing something terrible wrong, because it feels so? 我是不是在做一件可怕的错误,因为感觉如此?

Those files (part of the application and not a specific bundle) belong to the web directory as stated in the documentation: 这些文件(属于应用程序的一部分,而不是特定的捆绑软件)属于文档中所述的web目录:

The web root directory is the home of all public and static files including images, stylesheets, and JavaScript files. Web根目录是所有公共和静态文件(包括图像,样式表和JavaScript文件)的目录。

http://symfony.com/doc/current/book/page_creation.html#the-web-directory http://symfony.com/doc/current/book/page_creation.html#the-web-directory

EDIT 编辑

If you want your js and css to be compressed simply use: 如果要压缩js和CSS,请使用:

{% stylesheets 'public/css/*' filter='yui_cs' %}
      <link href="{{ asset_url }}" type="text/css" rel="stylesheet" />
{% endstylesheets %}

And

{% javascripts 'public/js/*' filter='yui_js' %}
      <script src="{{ asset_url }}"></script>
{% endjavascripts %}

You may need to change the filter name according to your configuration 您可能需要根据您的配置更改过滤器名称

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM