summaryrefslogtreecommitdiffstats
path: root/parser/pageparser/item.go
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 /parser/pageparser/item.go
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 'parser/pageparser/item.go')
-rw-r--r--parser/pageparser/item.go5
1 files changed, 5 insertions, 0 deletions
diff --git a/parser/pageparser/item.go b/parser/pageparser/item.go
index 0567bd8b9..644c20e87 100644
--- a/parser/pageparser/item.go
+++ b/parser/pageparser/item.go
@@ -42,6 +42,10 @@ func (i Item) IsShortcodeName() bool {
return i.Type == tScName
}
+func (i Item) IsInlineShortcodeName() bool {
+ return i.Type == tScNameInline
+}
+
func (i Item) IsLeftShortcodeDelim() bool {
return i.Type == tLeftDelimScWithMarkup || i.Type == tLeftDelimScNoMarkup
}
@@ -119,6 +123,7 @@ const (
tRightDelimScWithMarkup
tScClose
tScName
+ tScNameInline
tScParam
tScParamVal