3 ms·
Just asking "Does that work?" can demonstrate this. Slightly contrived example (I've trimmed the ChatGPT output down - it gives some warnings about code readabi
by stordoff 3y ago
Just asking "Does that work?" can demonstrate this. Slightly contrived example (I've trimmed the ChatGPT output down - it gives some warnings about code readability and that it only has knowledge up to 2022 that might be useful if the code worked at all):
> User: how can I pass two parameters to a hugo partial as positional parameters (without using a dict)?
> ChatGPT: If you want to pass parameters as positional arguments without using a dictionary, you might need to work around this limitation. One approach is to use a custom data structure, such as a slice or an array, to emulate positional parameters. Here's an example:
{{/* In your main template */}}
{{ partial "yourPartial.html" "value1" "value2" }}
{{/* In yourPartial.html */}}
{{ $param1 := index . 0 }}
{{ $param2 := index . 1 }}
[ChatGPT has also suggested in other runs that the values can be accessed with {{ .Param1 }} and {{ .Param2 }}]
> User: Does that work?
> ChatGPT: I apologize for the confusion in my previous response. I made an error in the example provided. Hugo's templating system doesn't support passing parameters as positional arguments directly, and my previous example was incorrect.
- otabdeveloper4 3y agoHave you tried asking it if it works when it gives a correct response? :)