Skip to content
● Grav 2.2 is out: 2x faster cold starts and 96% less memory on big sites. Read the announcement →

Css custom attributes not working

first-time theme

Solved by pamtbaau View solution

Started by Josh 6 years ago · 2 replies · 1312 views
6 years ago

Can someone help me understand why the code from the documentation is not working for me. I'm try to add custom attributes to my css load (so that I can bring in bootstrap) but custom attributes aren't working.

My code:
{% do assets.addCss('theme://css/styles.css',{'group':'mygroup'}) %} {{ assets.css('mygroup',{'rel':'alternate'}) }}

Is rendering as:
<link href="/user/themes/my-theme-name/css/styles.css" type="text/css" rel="stylesheet">

So... obviously not picking up my custom attribute. Here's the example from the documentation which is not working for me: https://learn.getgrav.org/16/themes/asset-manager#change-attribute-of-the-rendered-css-js-assets

Thanks.

6 years ago Solution

@skipper, Try switching on the 'pipeline' of css in '/user/config/system.yaml':

YAML
assets:
  css_pipeline: true

Note:

  • With css_pipeline: false, the options of assets.addCss(asset, [options]) are being used.
  • With css_pipeline: true, the options of assets.css(asset, [options]) are being used.

Same holds for assets.addJs() and assets.js()

last edited 08/13/20 by pamtbaau
6 years ago

Thank you. That got my attributes working.

Suggested topics

Topic Participants Replies Views Activity
Themes & Styling · by FrViPofm, 4 weeks ago
4 474 2 weeks ago
Themes & Styling · by johan thomas, 5 years ago
1 800 3 weeks ago
Themes & Styling · by stuart young, 2 months ago
3 660 2 months ago
Themes & Styling · by Sebadamus, 3 months ago
5 680 2 months ago
Themes & Styling · by martynfoster735, 3 months ago
1 642 3 months ago