Skip to content

Commit

Permalink
hugolib: Allow forward slash in shortcode names
Browse files Browse the repository at this point in the history
Fixes #4886
  • Loading branch information
bep committed Jun 28, 2018
1 parent 282f603 commit de37455
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
2 changes: 2 additions & 0 deletions hugolib/shortcodeparser.go
Original file line number Diff line number Diff line change
Expand Up @@ -464,6 +464,8 @@ Loop:
for {
switch r := l.next(); {
case isAlphaNumericOrHyphen(r):
// Allow forward slash inside names to make it possible to create namespaces.
case r == '/':
default:
l.backup()
word := l.input[l.start:l.pos]
Expand Down
3 changes: 3 additions & 0 deletions hugolib/shortcodeparser_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ var (
tstSC1 = item{tScName, 0, "sc1"}
tstSC2 = item{tScName, 0, "sc2"}
tstSC3 = item{tScName, 0, "sc3"}
tstSCSlash = item{tScName, 0, "sc/sub"}
tstParam1 = item{tScParam, 0, "param1"}
tstParam2 = item{tScParam, 0, "param2"}
tstVal = item{tScParamVal, 0, "Hello World"}
Expand All @@ -45,6 +46,8 @@ var shortCodeLexerTests = []shortCodeLexerTest{
{"no markup", `{{< sc1 >}}`, []item{tstLeftNoMD, tstSC1, tstRightNoMD, tstEOF}},
{"with EOL", "{{< sc1 \n >}}", []item{tstLeftNoMD, tstSC1, tstRightNoMD, tstEOF}},

{"forward slash inside name", `{{< sc/sub >}}`, []item{tstLeftNoMD, tstSCSlash, tstRightNoMD, tstEOF}},

{"simple with markup", `{{% sc1 %}}`, []item{tstLeftMD, tstSC1, tstRightMD, tstEOF}},
{"with spaces", `{{< sc1 >}}`, []item{tstLeftNoMD, tstSC1, tstRightNoMD, tstEOF}},
{"mismatched rightDelim", `{{< sc1 %}}`, []item{tstLeftNoMD, tstSC1,
Expand Down

0 comments on commit de37455

Please sign in to comment.