3
votes

I have imported the client side of my web app to

/bundle/Resources/views

This includes html documents, as well as the css, js, images and fonts folders. When i open an html page in a browser, it renders fine. But just by changing the extension of the file to .html.twig and rendering it through the symfony2 framework disables css.

I have also copied the css, js, images and font folders to

/bundle/Resources/public

I have also tried using the twig assets('') function with no luck.

What's going on?

2

2 Answers

5
votes

First execute app/console assets:install ( consider adding --symlink ). The command will copy/symlink all your bundle's Resources/public to web/bundles and create a folder in there named as the lowercase bundle-name without a trailing "Bundle".

example:

YourAwesomeBundle\Resources\public\css\style.css will be copied/symlinked to web\bundles\yourawesome\css\style.css

... afterwards include the assets using asset("@YourBundle/Resources/public/css/style.css")

... or asset("bundles/your/css/style.css")

0
votes

Exampe:

css

{% stylesheets '@TestBundle/Resources/public/css/*' filter='cssrewrite' %}
    <link rel="stylesheet" href="{{ asset_url }}" />
{% endstylesheets %}

js

{% javascripts '@TestBundle/Resources/public/js/*' %}
    <script type="text/javascript" src="{{ asset_url }}"></script>
{% endjavascripts %}