[Solved] Using params for linear-gradient

  • in md file, I was set as like follow
    +++
    title = “title”
    background = “…/img/innerpage/news2.png”
    gradient = “to top,rgba(132, 234, 209, 0.9), rgba(0, 149, 233, 0.9)”
    +++

  • in single.html, setted as like follow

          {{ if isset .Params "gradient" }}
          <div id="heading-breadcrumbs" style="background:linear-gradient({{ .Params.gradient }}), url({{.Params.background}}) center center no-repeat; background-size: cover;">
          {{ else }}
    
  • in result (can see in inspect mode)

         <div id="heading-breadcrumbs" style="background:linear-gradient(ZgotmplZ), url(../img/innerpage/news2.png) center center no-repeat; background-size: cover;">
    
  • what I expect is to get gradient parameter value in result.

Please kindly let me know what I was wrong.
Thanks

1 Like

guessing, but maybe you need to pipe that to safeHTML.

linear-gradient({{ .Params.gradient | safeHTML }})

Also, the “curly quotes” in your toml example are just a copy-paste artifact, right?

I was tried as like that.
But same result was got.

Ok, search the manual for safeXXXXX, and maybe try piping to safeCSS?

:slight_smile: working. I was missed this “safeCSS”.
Thanks for your helping.
Regards.

1 Like