Skip to content

golang template parse error while parsing index.html #373

Open
@freddyisaac

Description

@freddyisaac

Describe the bug

The file client/build/index.html throws an error when parsed by the golang html/template package.

To Reproduce

Steps to reproduce the behavior:

  1. build server using ./scripts/build.prod.sh --server
  2. execute the server ./build/ratel

Expected behavior

I would have expected the error not to occur

Screenshots

The exact error is

panic: Error parsing "index.html" contents

goroutine 1 [running]:
github.com/dgraph-io/ratel/server.prepareIndexContent()
/home/freddy.isaac/projects/ratel/server/server.go:112 +0x4c8
github.com/dgraph-io/ratel/server.Run()
/home/freddy.isaac/projects/ratel/server/server.go:42 +0x25
main.main()
/home/freddy.isaac/projects/ratel/main.go:11 +0xf

It is occurring on line 17 of the file index.html which is currently

       function isTemplateAnnotation(str) {
            return (
                str.indexOf("{{") === 0 &&
                str.lastIndexOf("}}") === str.length - 2
            );
        }

However changing this code to be

       function isTemplateAnnotation(str) {
            return str.indexOf("{{") === 0 && str.lastIndexOf("}}") === str.length - 2;
        }

does however parse OK!

I believe that this may be an issue with the golang html/template package and have opened a ticket here to clarify

golang/go#73061

Environment

  • OS: Ubuntu
  • Go
  • v1.24.1 but I have verified this back as far as v1.16

Additional context

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions