On 5/31/23 12:08 AM, John Xu wrote:
>When render vibe.d diet template,
string[] allMembers = __traits(allMembers, t);
enum allMembers = __traits(allMembers, t);
>res.render!("index.dt", t, allMembers)
if I don't want write memberName one by one in diet template:
table
- foreach(memberName; allMembers)
tr
td #{memberName}
td #{getTMember!memberName(t)}
Problem: memberName is not known at compile time.
The problem is that you stored the member name list as a runtime variable, and that is not known at compile time. Try the enum.
Or really, just foreach(memberName; __traits(allMembers, t))
right in the diet template.
-Steve