Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Undefined variable #36

Open
okay-scam opened this issue Oct 16, 2024 · 3 comments
Open

Undefined variable #36

okay-scam opened this issue Oct 16, 2024 · 3 comments

Comments

@okay-scam
Copy link

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:
@thomas-parodi
Copy link

it works for me, you have to fix your post request (no comma after "sam.n")

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"
  }
}'

@S3rth3ntia
Copy link

S3rth3ntia commented Oct 23, 2024 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants
@okay-scam @thomas-parodi @S3rth3ntia and others