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

webc:if doesn't preclude the need for optional chaining #191

Open
ghost opened this issue Aug 9, 2023 · 0 comments
Open

webc:if doesn't preclude the need for optional chaining #191

ghost opened this issue Aug 9, 2023 · 0 comments

Comments

@ghost
Copy link

ghost commented Aug 9, 2023

 <tail-cta webc:if="tail_cta" 
   :@lead="tail_cta?.lead"
   :@logos="tail_cta?.logos" 
   :@href="tail_cta?.href ?? '/get-started/'" 
   :@button-text="tail_cta?.button_text ?? 'Book a call'"
 ></tail-cta>

If I remove any of the ?.s, this happens regardless of whether the value is undefined:

[11ty] Problem writing Eleventy templates: (more in DEBUG output)
[11ty] 1. Having trouble writing to "dist/index.html" from "./src/index.webc" (via EleventyTemplateError)
[11ty] 2. Evaluating a dynamic prop failed: `:@button-text="tail_cta.button_text ?? 'Book a call'"`.
[11ty] Original error message: Cannot read properties of undefined (reading 'button_text') (via Error)
[11ty]
[11ty] Original error stack trace: Error: Evaluating a dynamic prop failed: `:@button-text="tail_cta.button_text ?? 'Book a call'"`.
[11ty] Original error message: Cannot read properties of undefined (reading 'button_text')

Doesn't make sense to me.

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

0 participants