Can't get module CSS to render
Created 7 years ago by edster

I have tried multiple iterations of the below $this->asset->style('emange.module.calendar::packages/fullcalendar/fullcalendar.css'); $this->asset->styles('emange.module.calendar::packages/fullcalendar/fullcalendar.print.css');

{{ asset_add("styles.css", "emange.module.calendar::packages/fullcalendar/fullcalendar.css") }}
{{ asset_add("styles.css", "emange.module.calendar::packages/fullcalendar/fullcalendar.print.css") }}

My theme has the below in it, but nothing is being spat out of it.

{% for style in asset_styles("styles.css") %}
    {{ style|raw }}
{% endfor %}
ryanthompson  —  7 years ago

You either need to defer your metadata block or add the assets via API in the controller. Your head is pry being processed early.

edster  —  7 years ago

Hey @ryanthompson I tried that, with both

$this->asset->styles('emange.module.calendar::packages/fullcalendar/fullcalendar.print.css');```

And they didn't work eaither,

{% for style in asset_styles("styles.css") %} {{ style|raw }} {% endfor %}


just returned empty :/
ryanthompson  —  7 years ago

Where do you add / render these?

edster  —  7 years ago
$this->asset->style('emange.module.calendar::packages/fullcalendar/fullcalendar.css'); 
$this->asset->styles('emange.module.calendar::packages/fullcalendar/fullcalendar.print.css');

^^Were in my Controller right before render

{% for style in asset_styles("styles.css") %}
    {{ style|raw }}
{% endfor %}

^^ Is in the head of my theme

ryanthompson  —  7 years ago

Have you ensured that the path is correct? These would be in resources/packages/fullcalendar/fullcalendar.css. Nothing there looks out of order though. Perhaps a bug but that would be very odd. How are you instantiating the Asset class in your controller? Method injection?

edster  —  7 years ago

So I got it to work by using

$this->asset->add('vendor.css', 'emange.module.calendar::packages/fullcalendar/fullcalendar.css', ['min']);

This is not preferred due to the ordering of my CSS files. I tried adding it to a different name (module.css) and render that out but it craps out saying there is no module.css file to render.

I'm not calling asset anywhere, it was just available as part of $this

I'm also trying to find out how to throw assets into 'media' => print but $asset->add doesn't seem to support it.