I am trying to add style sheets to an array, so when the branch templates go through the second and third levels, the generated aggregate styles.
This section is related to Asset Resource Combination through Inherited Templates.
From config.yml I made a global array of mystyles to add to the list of needed styles when we βbubbleβ through the rendering process.
twig: debug: %kernel.debug% strict_variables: %kernel.debug% globals: mystyles: []
The first template that is called from my action is from CommunicatorBundle / Resources / views / Admin / Workspace.html.twig , and I set the admin.workspace.css special style for this page.
{% extends "DJCommunicatorBundle::base.html.twig" %} {% set mystyles = ["@DJCommunicatorBundle/Resources/public/css/admin.workspace.css"]|merge(mystyles) %}
It extends CommunicatorBundle / Resources / views / base.html.twig , which has its own data-table.css .
{% extends "DJSharedBundle::base.html.twig" %} {% set mystyles = ["@DJCommunicatorBundle/Resources/public/css/data-table.css" ]|merge(mystyles) %}
Finally, we load the external template, SharedBundle / Resources / views / base.html.twig , which has its own styles to add in front of everyone else.
<head> {% set mystyles = ['@DJSharedBundle/Resources/public/css/global.css', '@DJSharedBundle/Resources/public/css/grid.990.9-col.css']|merge(mystyles) %} {% stylesheets {{ mystyles }} %} <link rel="stylesheet" href="{{ asset_url }}" type="text/css" /> {% endstylesheets %} </head>
However, it breaks into this line
{% stylesheets {{ mystyles }} %}
inspires this type of test, which prints an array that I expect in the correct order
{{ mystyles|join(', ') }}
It seems that the {% stylesheets %} tag wants something like the following snippit to work (which, obviously, is not an array object, but a space-separated list of delimited strings).
{% stylesheets '@DJSharedBundle/Resources/public/css/global.css' '@DJSharedBundle/Resources/public/css/grid.990.9-col.css' '@DJCommunicatorBundle/Resources/public/css/data-table.css' '@DJCommunicatorBundle/Resources/public/css/admin.workspace.css' %} <link rel="stylesheet" href="{{ asset_url }}" type="text/css" /> {% endstylesheets %}
Even then, I tried to set the string to such a long value and print it, but this also does not work:
{% set str = "@DJSharedBundle/Resources/public/css/global.css @DJSharedBundle/Resources/public/css/grid.990.9-col.css @DJCommunicatorBundle/Resources/public/css/data-table.css @DJCommunicatorBundle/Resources/public/css/admin.workspace.css" %} {% stylesheets {{ str }} %}
I feel that global should be a viable solution, although it currently does not work. I hope I'm around. What can this fix?