Skip to content
Grav 2.0 is officially stable. Read the announcement →
Archive

Using do addInlineCss() in partials?

Started by Muut Archive 10 years ago · 4 replies · 619 views
10 years ago

Is this supposed to work?

I'm trying to add to my inline style with this in a partial included in base.html.twig using {% include 'xxx-xxx.html.twig' %}but it isn't working. If i add the same {% do assets.addInlineCss('') %} in base.html.twig it works.

10 years ago

How does your rendered page source look, is there something wrong with it, or does the inline css not appear at all? Is the link correct: 'xxx-xxx.html.twig' and not 'partials/xxx-xxx.html.twig'?

10 years ago

The source code shows the content of the partial. I also see my other inline CSS added by the various modules of the modular page. The added CSS by the xxx-xxx.html.twig partial is the only thing missing.

10 years ago

I just checked {{ dump(assets) }} to see that my inline CSS test is there. It's the .aaaaa{...} part at the end:

JS
  Grav\Common\Assets {#34
  #fetch_command: null
  #css_pipeline: false
  #css_pipeline_include_externals: true
  #css_pipeline_before_excludes: true
  #js_pipeline: false
  #js_pipeline_include_externals: true
  #js_pipeline_before_excludes: true
  #inline_css: array:4 [
    "5827723666129bb6d49f8bc832e25064" => array:4 [
      "priority" => 10
      "order" => 0
      "asset" => "#divX {color: #ffffff;background-color: #112234;background-attachment: scroll;background-repeat: no-repeat;background-size: auto;background-position: left top;position: relative;}"
      "group" => "head"
    ]
    "3d54eeeb139d873ec9bf7620e21c10dc" => array:4 [
      "priority" => 10 
      "order" => 1
      "asset" => "#divXX{color:#dc291e}"
      "group" => "head"
    ]
    "c7d1d9e0ada98ab35fe26fd8bf2410b9" => array:4 [
      "priority" => 10
      "order" => 2
      "asset" => "#divXXX {color: #ffffff;} #divXXX .pllx {background-color: #112234;} @media screen and (min-width: 40em) {#divXXX .pllx {background-image: url();}}"
      "group" => "head"
    ]
    "48aae6f0af64059334a52992eefe72ce" => array:4 [
      "priority" => 10
      "order" => 3
      "asset" => ".aaaa { background:red; }"
      "group" => "head"
    ]
  ]
10 years ago

If I put {{ assets.css() }} at the very bottom of base.html.twig the inlined CSS in my menu small-menu-li.html.twig (called xxx-xxx.html.twig in previous posts) shows correctly.

Suggested topics

Topic Participants Replies Views Activity
Archive · by Deleted User, 9 years ago
0 1352 9 years ago
Archive · by Muut Archive, 9 years ago
2 935 9 years ago
Archive · by Muut Archive, 9 years ago
2 4064 9 years ago
Archive · by Muut Archive, 9 years ago
1 2949 9 years ago
Archive · by Muut Archive, 9 years ago
3 1119 9 years ago