Using safeCSS with partials

I inline CSS in the head of my template like this:

<style>
  {{ partial "css-default.html" . }}
</style>

This triggers the ZgotmplZ value in the HTML code, caused by unsafe CSS content reached (docs). But how can we apply safeCSS to a partial?

This generates an error:

{{ partial "css-default-trascr.html" . | safeCSS }}

executing "theme/partials/head.html" at <safeCSS>: wrong typ
e for value; expected string; got template.HTML in theme/partials/head.html

This also generates an error:

{{ partial "css-default-trascr.html" | safeCSS . }}

executing "theme/partials/head.html" at <safeCSS>: wrong num
ber of args for safeCSS: want 1 got 1 in theme/partials/head.html

(Off-topic: perhaps this latter message can be improved: want 1 got 1 sound odd, doesn’t it? )

try {{ partial "css-default-trascr.html" . | print | safeCSS }} . :slight_smile:

Thanks for responding. I don’t use inline CSS anymore but store CSS in separate files to adhere to that HTTP/2 best practice.

(Other people finding this thread will find your reply helpful though.) :slightly_smiling: