github.com/rabbouni145/gg@v0.47.1/docs/content/en/functions/safeCSS.md (about)

     1  ---
     2  title: safeCSS
     3  description: Declares the provided string as a known "safe" CSS string.
     4  godocref: https://golang.org/src/html/template/content.go?s=919:929#L15
     5  date: 2017-02-01
     6  publishdate: 2017-02-01
     7  lastmod: 2017-02-26
     8  categories: [functions]
     9  menu:
    10    docs:
    11      parent: "functions"
    12  keywords: [style,css,strings]
    13  signature: ["safeCSS INPUT"]
    14  workson: []
    15  hugoversion:
    16  relatedfuncs: [safeHTML,safeHTMLAttr,]
    17  deprecated: false
    18  aliases: []
    19  ---
    20  
    21  In this context, *safe* means CSS content that matches any of the following:
    22  
    23  1. The CSS3 stylesheet production, such as `p { color: purple }`.
    24  2. The CSS3 rule production, such as `a[href=~"https:"].foo#bar`.
    25  3. CSS3 declaration productions, such as `color: red; margin: 2px`.
    26  4. The CSS3 value production, such as `rgba(0, 0, 255, 127)`.
    27  
    28  Example: Given `style = "color: red;"` defined in the front matter of your `.md` file:
    29  
    30  * <span class="good">`<p style="{{ .Params.style | safeCSS }}">…</p>` &rarr; `<p style="color: red;">…</p>`</span>
    31  * <span class="bad">`<p style="{{ .Params.style }}">…</p>` &rarr; `<p style="ZgotmplZ">…</p>`</span>
    32  
    33  {{% note "ZgotmplZ" %}}
    34  "ZgotmplZ" is a special value that indicates that unsafe content reached a CSS or URL context.
    35  {{% /note %}}
    36