stencilproject/Stencil

Passing string argument with `=` on the end injects a `1` instead of the content of the arg

batonPiotr opened this issue · 1 comments

I use Stencil with following params (where PROJECT_NAME is the name of the project I am working on):

./Pods/Sourcery/bin/sourcery --templates ./PROJECT_NAME --sources . --output ./PROJECT_NAME --args password="$BACKEND_PASSWORD",login="$BACKEND_LOGIN"

The stencil file looks like this:
public let backendCreds = BackendCredentials(login: "{{ argument.login }}", password: "{{ argument.password }}")

and produced output looks like this:
public let backendCreds = BackendCredentials(login: "CORRECT_VALUE", password: "1")

BACKEND_LOGIN contains a = at the end of the string. When I remove it, it works fine. When I echoe the value just right before this command, the printed string is correct, so the variable contains the correct string too. It must be broken somewhere afterwards.

djbe commented

I've tried reproducing your issue with the following test, and it works as it should, I'm not getting the 1 value you're getting:

func testBug() throws {
  let template: Template = """
  public let backendCreds = BackendCredentials(login: "{{ argument.login }}", password: "{{ argument.password }}")
  """
  let result = try template.render(["argument": ["login": "Kyle", "password": "blabla="]])

  try expect(result) == """
  public let backendCreds = BackendCredentials(login: "Kyle", password: "blabla=")
  """
}

Are you using Stencil on your own, or within another tool such as Sourcery or SwiftGen? If so, the issue may be there. Seeing as you're using arguments makes me think this may have something to do with the StencilSwiftKit parameters parser.