# I have a scenario for people experienced with templates, I don't nearly know # enough: # <../util.nim> import std/tables const TYPE_COLORS = {"type1": "red", ...}.to_table() proc date_formatter(in_stamp: string): string = ... # import std/tables import std/strformat import ../util.nim proc generic_metadata_printer( struct: MetadataType1 | MetadataType2 ): string = # Am I supposed to `bind` or `mixin` here? Neither works... # Both `MetadataType1` and `MetadataType2` have the field `event_stamp` result &= &"Let's format a datestamp: {date_formatter(struct.event_stamp)}\n" result &= &"Let's also pick a color: {TYPE_COLORS[struct.type]}\n" ... # Both `date_formatter` and `TYPE_COLORS` throw "Error: undeclared identifier". # Unsure how to make these symbols visible to the `&` template inside # my generic template proc.