Skip to content

Undefined variable #36

@okay-scam

Description

@okay-scam

No matter what I do, I can't get the pdf to render using Gotenberg.

The PDF only ever renders with
Failed to render HTML. Error: Undefined variable $username

My template
<h2>Hello {{ $username }}</h2>

Default variables

{
  "username": "username_missing"
}

cURL

curl --request POST \
  --url http://localhost:8888/api/v1/document-templates/9d4186c0-4bd0-4732-8fb0-2944132d31b1/pdfs \
  --header 'content-type: application/json' \
  --data '{
  "variables": {
    "username": "sam.n",
  }
}'

docker log

docking-1    | {"message":"Undefined variable $username","context":{"view":{"view":"/var/www/html/storage/framework/views/8d5b3624fbd57ccbbace3317aac77a67.blade.php","data":[]},"exception":{"class":"Spatie\\LaravelIgnition\\Exceptions\\ViewException","message":"Undefined variable $username","code":0,"file":"/var/www/html/storage/framework/views/8d5b3624fbd57ccbbace3317aac77a67.blade.php:1","previous":{"class":"ErrorException","message":"Undefined variable $username","code":0,"file":"/var/www/html/storage/framework/views/464daea1acbb9d2710318291b7aff0fb.php:1"}}},"level":400,"level_name":"ERROR","channel":"production","datetime":"2024-10-16T03:07:49.538753+00:00","extra":{}}
gotenberg-1  | {"level":"info","ts":1729048069.5986624,"logger":"api","msg":"request handled","trace":"736acea2-312e-4c0f-ac86-89ae30600cb9","remote_ip":"172.18.0.3","host":"gotenberg:3000","uri":"/forms/chromium/convert/html","method":"POST","path":"/forms/chromium/convert/html","referer":"","user_agent":"GuzzleHttp/7","status":200,"latency":53202208,"latency_human":"53.202208ms","bytes_in":267,"bytes_out":20134}

Running with docker-compose.yml

services:
  docking:
    image: "ghcr.io/shipsaas/docking:latest"
    env_file: .env
    volumes:
      - ./docking.sqlite:/var/www/html/docking.sqlite
      - app_storage:/var/www/html/storage/app
    links:
      - gotenberg
    ports:
      - '8888:80'

  gotenberg:
    image: gotenberg/gotenberg:8

volumes:
  app_storage:

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