Use forward slash before template variable

152 Views Asked by At

For quite some time I am now trying to get the following template to work with twirl:

    @for(service <- services) {
        location /grpc/@service {
            grpc_pass @service:8088;
        }
    }

services is a List[String]. While the template is properly converted into a scala template, that scala template does not compile:

nginx.template.scala:40: type mismatch;
 found   : play.twirl.api.TxtFormat.Appendable
    (which expands to)  play.twirl.api.Txt
 required: Int

With line 40 being:

      """),format.raw/*18.9*/("""location /grpc/"""),_display_(/*18.25*/service/*18.32*/ {_display_(Seq[Any](format.raw/*18.34*/("""

Checking that file out in IntelliJ does not show any error on that line. Changing it to location @service works as expected.

Do I need to escape the forward slash somehow?

1

There are 1 best solutions below

0
Yanick Salzmann On

The following seems to fix the issue:

location /grpc/@{service}