Skip to content

Commit

Permalink
fix: allow underscores in template calls (#118)
Browse files Browse the repository at this point in the history
  • Loading branch information
joerdav authored Jul 28, 2023
1 parent 92839c3 commit df253a6
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
1 change: 1 addition & 0 deletions parser/v2/templelementparser.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ var templElementStartExpressionParams = parse.StringFrom(
var templElementStartExpression = ExpressionOf(parse.StringFrom(
parse.AtLeast(1, parse.StringFrom(
parse.StringFrom(parse.Optional(parse.String("."))),
parse.StringFrom(parse.Optional(parse.String("_"))),
parse.RuneInRanges(unicode.Letter),
parse.StringFrom(parse.AtMost(255, parse.RuneInRanges(unicode.Letter, unicode.Number))),
parse.StringFrom(parse.Optional(templElementStartExpressionParams)),
Expand Down
23 changes: 22 additions & 1 deletion parser/v2/templelementparser_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
)

func TestTemplElementExpressionParser(t *testing.T) {
var tests = []struct {
tests := []struct {
name string
input string
expected TemplElementExpression
Expand All @@ -34,6 +34,27 @@ func TestTemplElementExpressionParser(t *testing.T) {
},
},
},
{
name: "templelement: simple with underscore",
input: `@Other_Component(p.Test)` + "\n",
expected: TemplElementExpression{
Expression: Expression{
Value: "Other_Component(p.Test)",
Range: Range{
From: Position{
Index: 1,
Line: 0,
Col: 1,
},
To: Position{
Index: 24,
Line: 0,
Col: 24,
},
},
},
},
},
{
name: "templelement: simple, block with text",
input: `@Other(p.Test) {
Expand Down

0 comments on commit df253a6

Please sign in to comment.