summaryrefslogtreecommitdiffstats
path: root/common/herrors
diff options
context:
space:
mode:
authorBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2018-11-26 11:01:27 +0100
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2018-11-27 16:14:09 +0100
commitbc337e6ab5a75f1f1bfe3a83f3786d0afdb6346c (patch)
tree1f3b087822337acbde696147f18e86b2c9f1d8eb /common/herrors
parent112461fded0d7970817ce7bf476c4763922ad314 (diff)
Add inline shortcode support
An inline shortcode's name must end with `.inline`, all lowercase. E.g.: ```bash {{< time.inline >}}{{ now }}{{< /time.inline >}} ``` The above will print the current date and time. Note that an inline shortcode's inner content is parsed and executed as a Go text template with the same context as a regular shortcode template. This means that the current page can be accessed via `.Page.Title` etc. This also means that there are no concept of "nested inline shortcodes". The same inline shortcode can be reused later in the same content file, with different params if needed, using the self-closing syntax: ``` {{< time.inline />}} ``` Fixes #4011
Diffstat (limited to 'common/herrors')
-rw-r--r--common/herrors/file_error.go8
1 files changed, 7 insertions, 1 deletions
diff --git a/common/herrors/file_error.go b/common/herrors/file_error.go
index 929cc800f..5af84adf5 100644
--- a/common/herrors/file_error.go
+++ b/common/herrors/file_error.go
@@ -92,7 +92,13 @@ func UnwrapFileError(err error) FileError {
// with the given offset from the original.
func ToFileErrorWithOffset(fe FileError, offset int) FileError {
pos := fe.Position()
- pos.LineNumber = pos.LineNumber + offset
+ return ToFileErrorWithLineNumber(fe, pos.LineNumber+offset)
+}
+
+// ToFileErrorWithOffset will return a new FileError with the given line number.
+func ToFileErrorWithLineNumber(fe FileError, lineNumber int) FileError {
+ pos := fe.Position()
+ pos.LineNumber = lineNumber
return &fileError{cause: fe, fileType: fe.Type(), position: pos}
}