Can't get module CSS to render

edster - 1 year ago

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 - 1 year 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 - 1 year ago

Hey @ryanthompson I tried that, with both $this->asset->style('emange.module.calendar::packages/fullcalendar/fullcalendar.css'); $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 - 1 year ago

Where do you add / render these?

edster - 1 year 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 $this->asset->style('emange.module.calendar::packages/fullcalendar/fullcalendar.css'); $this->asset->styles('emange.module.calendar::packages/fullcalendar/fullcalendar.print.css');

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

^^ Is in the head of my theme

ryanthompson - 1 year 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 - 1 year 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.