mirror of
https://github.com/gohugoio/hugo.git
synced 2024-05-11 05:54:58 +00:00
Squashed 'docs/' changes from 20959c7b..36d7e22f
36d7e22f Document fmt.{print, println} template functions 79a72fce Fix link to page variables 00342ca9 Fix broken link on highlight page 15f44952 Fix link in v0.28 release notes 0100df73 Fix code examples for math.{Ceil, Floor, Round} a354a69b Fix broken netlify.toml 4995e5df Merge branch 'master' of github.com:gohugoio/hugoDocs 9cdd990a Hugo 0.29 463558f9 Document math.Log template function 588499af Add nohup.out to .gitignore db8ddcf7 Change name of post files in example to use post prefix 296ec01f Add ox-hugo Emacs package to the tools section f060d6d1 Fix math.Ceil, Floor, and Round naming a2262d24 Document strings.TrimPrefix and TrimSuffix template functions 80c1ce63 Document strings.TrimLeft and TrimRight template functions 2921088d Document urls.Parse template function f0133079 Document math.{ceil, floor, round} template functions 82863808 Fix typo in migration tools section d5215d61 Add link to syntax hl docs in release notes 541f0686 Update versions 275ce2b4 Update 0.28 release notes 886713a1 Add release notes for 0.28 bed02e5f Merge branch 'next' 8e3b1ac4 Add a note about branches 1662b9d0 Add missing Disqus links in templates/internal.md git-subtree-dir: docs git-subtree-split: 36d7e22f5c21c550bd87782d2ddca666178fe1ff
This commit is contained in:
@@ -25,4 +25,4 @@ See [Installing Hugo][installpygments] for more information on Pygments or [Synt
|
||||
|
||||
[highlight]: /content-management/shortcodes/#highlight
|
||||
[installpygments]: /getting-started/installing/#installing-pygments-optional
|
||||
[syntax]: /tools/syntax-highlighting/
|
||||
[syntax]: /content-management/syntax-highlighting/
|
||||
|
@@ -1,6 +1,6 @@
|
||||
---
|
||||
title: Math
|
||||
description: Hugo provides six mathematical operators in templates.
|
||||
description: Hugo provides nine mathematical operators in templates.
|
||||
godocref:
|
||||
date: 2017-02-01
|
||||
publishdate: 2017-02-01
|
||||
@@ -20,14 +20,14 @@ draft: false
|
||||
aliases: []
|
||||
---
|
||||
|
||||
There are 6 basic mathematical operators that can be used in Hugo templates:
|
||||
|
||||
| Function | Description | Example |
|
||||
| -------- | ------------------------ | ----------------------------- |
|
||||
| `add` | Adds two integers. | `{{add 1 2}}` → 3 |
|
||||
| `div` | Divides two integers. | `{{div 6 3}}` → 2 |
|
||||
| `mod` | Modulus of two integers. | `{{mod 15 3}}` → 0 |
|
||||
| `modBool`| Boolean of modulus of two integers. Evaluates to `true` if = 0. | `{{modBool 15 3}}` → true |
|
||||
| `mul` | Multiplies two integers. | `{{mul 2 3}}` → 6 |
|
||||
| `sub` | Subtracts two integers. | `{{sub 3 2}}` → 1 |
|
||||
|
||||
| Function | Description | Example |
|
||||
|----------------|-------------------------------------------------------------------------------|----------------------------------|
|
||||
| `add` | Adds two integers. | `{{add 1 2}}` → 3 |
|
||||
| `div` | Divides two integers. | `{{div 6 3}}` → 2 |
|
||||
| `mod` | Modulus of two integers. | `{{mod 15 3}}` → 0 |
|
||||
| `modBool` | Boolean of modulus of two integers. Evaluates to `true` if result equals 0. | `{{modBool 15 3}}` → true |
|
||||
| `mul` | Multiplies two integers. | `{{mul 2 3}}` → 6 |
|
||||
| `sub` | Subtracts two integers. | `{{sub 3 2}}` → 1 |
|
||||
| `math.Ceil` | Returns the least integer value greater than or equal to the given number. | `{{math.Ceil 2.1}}` → 3 |
|
||||
| `math.Floor` | Returns the greatest integer value less than or equal to the given number. | `{{math.Floor 1.9}}` → 1 |
|
||||
| `math.Round` | Returns the nearest integer, rounding half away from zero. | `{{math.Round 1.5}}` → 2 |
|
||||
|
26
content/functions/print.md
Normal file
26
content/functions/print.md
Normal file
@@ -0,0 +1,26 @@
|
||||
---
|
||||
title: print
|
||||
linktitle: print
|
||||
description: Prints the default representation of the given argument using the standard `fmt.Print` function.
|
||||
godocref: https://golang.org/pkg/fmt/
|
||||
date: 2017-02-01
|
||||
publishdate: 2017-02-01
|
||||
lastmod: 2017-02-01
|
||||
categories: [functions]
|
||||
menu:
|
||||
docs:
|
||||
parent: "functions"
|
||||
keywords: [strings]
|
||||
signature: ["print INPUT"]
|
||||
workson: []
|
||||
hugoversion:
|
||||
relatedfuncs: []
|
||||
deprecated: false
|
||||
---
|
||||
|
||||
See [the go doc](https://golang.org/pkg/fmt/) for additional information.
|
||||
|
||||
```
|
||||
{{ print "foo" }} → "foo"
|
||||
{{ print (slice 1 2 3) }} → [1 2 3]
|
||||
```
|
25
content/functions/println.md
Normal file
25
content/functions/println.md
Normal file
@@ -0,0 +1,25 @@
|
||||
---
|
||||
title: println
|
||||
linktitle: println
|
||||
description: Prints the default representation of the given argument using the standard `fmt.Print` function and enforces a linebreak.
|
||||
godocref: https://golang.org/pkg/fmt/
|
||||
date: 2017-02-01
|
||||
publishdate: 2017-02-01
|
||||
lastmod: 2017-02-01
|
||||
categories: [functions]
|
||||
menu:
|
||||
docs:
|
||||
parent: "functions"
|
||||
keywords: [strings]
|
||||
signature: ["println INPUT"]
|
||||
workson: []
|
||||
hugoversion:
|
||||
relatedfuncs: []
|
||||
deprecated: false
|
||||
---
|
||||
|
||||
See [the go doc](https://golang.org/pkg/fmt/) for additional information. `\n` denotes the linebreak but isn't printed in the templates as seen below:
|
||||
|
||||
```
|
||||
{{ println "foo" }} → "foo\n"
|
||||
```
|
28
content/functions/strings.TrimLeft.md
Normal file
28
content/functions/strings.TrimLeft.md
Normal file
@@ -0,0 +1,28 @@
|
||||
---
|
||||
title: strings.TrimLeft
|
||||
description: Returns a slice of a given string with all leading characters contained in the cutset removed.
|
||||
godocref:
|
||||
date: 2017-02-01
|
||||
publishdate: 2017-02-01
|
||||
lastmod: 2017-02-01
|
||||
categories: [functions]
|
||||
menu:
|
||||
docs:
|
||||
parent: "functions"
|
||||
keywords: [strings]
|
||||
signature: ["strings.TrimLeft CUTSET STRING"]
|
||||
workson: []
|
||||
hugoversion:
|
||||
relatedfuncs: [strings.TrimRight]
|
||||
deprecated: false
|
||||
aliases: []
|
||||
---
|
||||
|
||||
Given the string `"abba"`, leading `"a"`'s can be removed a follows:
|
||||
|
||||
{{ strings.TrimLeft "abba" "a" }} → "bba"
|
||||
|
||||
Numbers can be handled as well:
|
||||
|
||||
{{ strings.TrimLeft 1221 "12" }} → ""
|
||||
|
25
content/functions/strings.TrimPrefix.md
Normal file
25
content/functions/strings.TrimPrefix.md
Normal file
@@ -0,0 +1,25 @@
|
||||
---
|
||||
title: strings.TrimPrefix
|
||||
description: Returns a given string s without the provided leading prefix string. If s doesn't start with prefix, s is returned unchanged.
|
||||
godocref:
|
||||
date: 2017-02-01
|
||||
publishdate: 2017-02-01
|
||||
lastmod: 2017-02-01
|
||||
categories: [functions]
|
||||
menu:
|
||||
docs:
|
||||
parent: "functions"
|
||||
keywords: [strings]
|
||||
signature: ["strings.TrimPrefix PREFIX STRING"]
|
||||
workson: []
|
||||
hugoversion:
|
||||
relatedfuncs: [strings.TrimSuffix]
|
||||
deprecated: false
|
||||
aliases: []
|
||||
---
|
||||
|
||||
Given the string `"aabbaa"`, the specified prefix is only removed if `"aabbaa"` starts with it:
|
||||
|
||||
{{ strings.TrimPrefix "a" "aabbaa" }} → "abbaa"
|
||||
{{ strings.TrimPrefix "aa" "aabbaa" }} → "bbaa"
|
||||
{{ strings.TrimPrefix "aaa" "aabbaa" }} → "aabbaa"
|
28
content/functions/strings.TrimRight.md
Normal file
28
content/functions/strings.TrimRight.md
Normal file
@@ -0,0 +1,28 @@
|
||||
---
|
||||
title: strings.TrimRight
|
||||
description: Returns a slice of a given string with all trailing characters contained in the cutset removed.
|
||||
godocref:
|
||||
date: 2017-02-01
|
||||
publishdate: 2017-02-01
|
||||
lastmod: 2017-02-01
|
||||
categories: [functions]
|
||||
menu:
|
||||
docs:
|
||||
parent: "functions"
|
||||
keywords: [strings]
|
||||
signature: ["strings.TrimRight CUTSET STRING"]
|
||||
workson: []
|
||||
hugoversion:
|
||||
relatedfuncs: [strings.TrimRight]
|
||||
deprecated: false
|
||||
aliases: []
|
||||
---
|
||||
|
||||
Given the string `"abba"`, trailing `"a"`'s can be removed a follows:
|
||||
|
||||
{{ strings.TrimRight "abba" "a" }} → "abb"
|
||||
|
||||
Numbers can be handled as well:
|
||||
|
||||
{{ strings.TrimRight 1221 "12" }} → ""
|
||||
|
25
content/functions/strings.TrimSuffix.md
Normal file
25
content/functions/strings.TrimSuffix.md
Normal file
@@ -0,0 +1,25 @@
|
||||
---
|
||||
title: strings.TrimSuffix
|
||||
description: Returns a given string s without the provided trailing suffix string. If s doesn't end with suffix, s is returned unchanged.
|
||||
godocref:
|
||||
date: 2017-02-01
|
||||
publishdate: 2017-02-01
|
||||
lastmod: 2017-02-01
|
||||
categories: [functions]
|
||||
menu:
|
||||
docs:
|
||||
parent: "functions"
|
||||
keywords: [strings]
|
||||
signature: ["strings.TrimSuffix SUFFIX STRING"]
|
||||
workson: []
|
||||
hugoversion:
|
||||
relatedfuncs: [strings.TrimPrefix]
|
||||
deprecated: false
|
||||
aliases: []
|
||||
---
|
||||
|
||||
Given the string `"aabbaa"`, the specified suffix is only removed if `"aabbaa"` ends with it:
|
||||
|
||||
{{ strings.TrimSuffix "a" "aabbaa" }} → "aabba"
|
||||
{{ strings.TrimSuffix "aa" "aabbaa" }} → "aabb"
|
||||
{{ strings.TrimSuffix "aaa" "aabbaa" }} → "aabbaa"
|
32
content/functions/urls.Parse.md
Normal file
32
content/functions/urls.Parse.md
Normal file
@@ -0,0 +1,32 @@
|
||||
---
|
||||
title: urls.Parse
|
||||
description: Parse parses a given url, which may be relative or absolute, into a URL structure.
|
||||
godocref: https://godoc.org/net/url#URL
|
||||
date: 2017-09-25
|
||||
publishdate: 2017-09-25
|
||||
lastmod: 2017-09-25
|
||||
categories: [functions]
|
||||
menu:
|
||||
docs:
|
||||
parent: "functions"
|
||||
keywords: [urls]
|
||||
signature: ["urls.Parse URL"]
|
||||
workson: []
|
||||
hugoversion:
|
||||
deprecated: false
|
||||
aliases: []
|
||||
---
|
||||
|
||||
`urls.Parse` takes a url as input
|
||||
|
||||
|
||||
```
|
||||
{{ $url := urls.Parse "http://www.gohugo.io" }}
|
||||
```
|
||||
|
||||
and returns a [URL](https://godoc.org/net/url#URL) structure. The struct fields are accessed via the `.` notation:
|
||||
|
||||
```
|
||||
{{ $url.Scheme }} → "http"
|
||||
{{ $url.Host }} → "www.gohugo.io"
|
||||
```
|
Reference in New Issue
Block a user