Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest, windows-latest]
go: ['1.23', '1.22']
go: ['1.25', '1.24']
steps:
- uses: actions/checkout@v4

Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ func staticTest(_w io.Writer) {

}

func translateTest(t Translater, buf *bytes.Buffer) {
func translateTest(t Translater, _w io.Writer) {

{{t Translate me to some language }}

Expand Down Expand Up @@ -562,7 +562,7 @@ import {
}


func writeTemplate(ctx context.Context, buf *bytes.Buffer) {
func writeTemplate(ctx context.Context, _w io.Writer) {

{{# Define the body that will be inserted into the template }}
{{< body }}
Expand Down
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
module github.com/goradd/got

require (
github.com/goradd/gofile v1.2.0
github.com/stretchr/testify v1.8.4
github.com/goradd/gofile v1.2.1
github.com/stretchr/testify v1.11.1
)

require (
Expand Down
4 changes: 4 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,14 @@ github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/goradd/gofile v1.2.0 h1:sCHG3icAFGO8gwl5Yy8llvhlIl8k5uaYa6uE23Z56MA=
github.com/goradd/gofile v1.2.0/go.mod h1:ZjSvnGak2csGsJgEu8AgQc06eaoonhg2MzbqXON9o1M=
github.com/goradd/gofile v1.2.1 h1:rbUJ6HIoYWJxDqqRftceb48COv4M0HxkU5d8PdRElD4=
github.com/goradd/gofile v1.2.1/go.mod h1:ZjSvnGak2csGsJgEu8AgQc06eaoonhg2MzbqXON9o1M=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk=
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U=
github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
Expand Down
8 changes: 5 additions & 3 deletions internal/got/lexer.go
Original file line number Diff line number Diff line change
Expand Up @@ -524,14 +524,16 @@ func splitParams(paramString string) (params []string, err error) {
s.Init(strings.NewReader(paramString))
for tok := s.Scan(); tok != scanner.EOF; tok = s.Scan() {
text := s.TokenText()
if len(text) > 0 && text[0] == '"' && (len(text) == 1 || text[len(text)-1] != '"') {
if len(text) > 0 &&
(text[0] == '"' && (len(text) == 1 || text[len(text)-1] != '"') ||
(text[0] == '`' && (len(text) == 1 || text[len(text)-1] != '`'))) {
err = fmt.Errorf("parameter has a beginning quote with no ending quote: %s", text)
return
}
if text == "," {
currentItem = strings.TrimSpace(currentItem)
if currentItem != "" {
if currentItem[0] == '"' {
if currentItem[0] == '"' || currentItem[0] == '`' {
currentItem, err = strconv.Unquote(currentItem)
if err != nil {
return
Expand All @@ -548,7 +550,7 @@ func splitParams(paramString string) (params []string, err error) {
}
}
if currentItem != "" {
if currentItem[0] == '"' {
if currentItem[0] == '"' || currentItem[0] == '`' {
currentItem, err = strconv.Unquote(currentItem)
if err != nil {
return
Expand Down
2 changes: 1 addition & 1 deletion internal/got/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ func (p *parser) parseIf(item tokenItem) (items []tokenItem) {

default:
item.typ = itemError
item.val = "unexpected end block item"
item.val = "unexpected end block item: " + endItem.val
return []tokenItem{item}
}
}
Expand Down
4 changes: 4 additions & 0 deletions internal/testdata/expected/TestSub.out
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,7 @@ MeSubstituted:
You
Not Substituted:

Substituted:
You,"Me"
Not Substituted:
,
16 changes: 16 additions & 0 deletions internal/testdata/src/testSub.tpl.got
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ func TestSub(_w io.Writer) (err error) {
if err = myTest2(_w); err != nil {return}
if err = myTest3(_w); err != nil {return}
if err = myTest4(_w); err != nil {return}
if err = myTest5(_w); err != nil {return}
return
}

Expand Down Expand Up @@ -59,6 +60,21 @@ Not Substituted:
return
}

{{define fourth 2}}
$1,$2
{{end fourth}}

func myTest5(_w io.Writer) (err error) {
{{
Substituted:
{{fourth "You", `"Me"`}}
Not Substituted:
{{fourth}}
}}
return
}


func init() {
registry.RegisterTest(TestSub, "TestSub")
}