hugo

Fork of github.com/gohugoio/hugo with reverse pagination support

git clone git://git.shimmy1996.com/hugo.git

safeCSS.md (1159B)

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