So my question is: is there any way for me to have the template automatically pass through any “extra” attributes, such as title, that I invoke it with? Or do I have to hardcode the “whitelist” of allowed passthrough attributes?
You can use global attributes. There is a whitelist, but the default includes all HTML global attributes (title is one of those). You can explicitly whitelist others in the attr call.
Hmm, it looks like “key :rest not found” is the result if I add a <... title="..."> parameter to the invocation and a <... {@rest}> parameter inside the template.
Putting attr :rest, :global just before embed_templates "page_html/*" also leads to some incomprehensible compile-time errors on utility templates that used to be fine:
could not define attributes for function asset/1. Please make sure that you have use Phoenix.Component and that the function has no default arguments
Is there any way to configure Phoenix.Component.attr/3 within .heex templates, or will I have to refactor this to use .ex/def (assigns)/~H?
When you want to use attr / slot with an external .heex file you need to define an empty function head in the .ex file that has embed_templates. There’s an example in the docs: Phoenix.Component — Phoenix LiveView v1.1.11