-
Notifications
You must be signed in to change notification settings - Fork 11
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
How to import in Partial? #31
Comments
Hi, @stephenafamo , depending on your use case you might be able to inline the import:
But I think this might be problematic. I would recommend instead to put the logic in your view function to unpack the value into basic types and insert into your view data. If you want to share more details about your use case I can try to provide some suggestions, or maybe you will help me find some limitations in Zmpl that I can solve by adding new features. |
I've been able to sort of figure out the import in a fork, but I'm facing other problems since I can only pass primitive types to What I truly desire from zmpl is "Type-Safe Templates". The issue with zmpl's With partials requiring Args, I can almost get my desired type safety, but since I can't pass complex types down to the partials, I am forced to encode it to a string (maybe json) and then decode in the template The ideal scenario for me is that for each template, I can set the args (similar to partials) and those args will be the only data available to the template. NOTE: I am using only |
@stephenafamo Yeah I think that's a reasonable expectation. The reason for things working the way they do is because I want all template data to be JSON compatible, that way every endpoint can render HTML via Zmpl or JSON, so every Jetzig app gets a JSON API for free. But if that causes more problems than benefits then it's not the right design choice. Let me have a think about it, if I can find a nice way to allow adding arbitrary types to Zmpl without breaking existing functionality then I'll be happy to add it, and if you wanted to submit a PR then that would also be welcome. I think probably we can add template.renderT(MyType, my_value); I'm sure I can adapt the same approach to partials as well, since they are also just Zig functions under the hood. Maybe a new partial syntax like:
I'm on a train right now but I'll try to look at it this weekend. |
One way would be to check that it implements a |
Yeah, that one is already on the TODO list - anything that implements |
It should also be possible to extract the raw type from the |
You can use |
Thanks 👍🏾 |
Partials allow us to have args.
How can I add an import to the manifest so I can use an argument type from a different package in my partial?
The text was updated successfully, but these errors were encountered: