Macros, inheritance and headers

Hi all

I am creating twitter and linkedin cards, and want to pass the relevant info to meta in the header, and need to repeat the info as twitter and linkedin have different meta labels.

This is easily done with macros. But is far from elegant or safe.

Inheritance is elegant, but we can only use a block once, while I need the text in a block in several places in a header.

Can have multiple blocks with the same text, but that is not elegant or safe.

So, question is: What is the best way to pass text to a header and use it several times.

best, j

what’s not elegant or safe with a macro?

1 Like

Hi @keats

macros are of course elegant and safe generally, and I use several.

its just using base.html to set out the site, all the css and js and the like, and simply dropping content in the middle of it means there is one place to control all that is common for a site

Can replicate that with macros, but that is less elegant than inheritance from base.html.

And more to the point, having used inheritance in other languages, it feels better to me here.

Can just have index.html, blog.html. blog-page.html call a macro instead of inheriting, and my question was if that was the way forward.

best, j