Pass modular template variables to modules

Maybe I haven’t read it in the Grav documentation or seen any code examples in any templates, but the question is: how can variables be passed from a modular page to its modules?

It doesn’t seem like inheritance works here like it does in other templates (for example the default page which inherits the base template).
I have several modular templates that use the same code for some variables, and for them to work I have to define them in each template.
I can’t use extend, I can’t use include (the context is different), I can’t use blocks, etc.
Maybe I’m not doing it right or it just can’t be done.
Any suggestions?

1 Like

Any suggestions?

I have these common variables used in several modules templates:

{% set blog = page.find(header_var('blog_url')|defined(theme_var('blog_page'))) %}
{% set override_style = theme_var('override_page_style')|defined(false) %}
{% set color_style = override_style ? theme_var('default_page_style')|default('primary') :|defined('primary') %}
{% set page_title = page.title %}
{% set show_title = page.header.show_title|defined(false) %}

How can I inherit from some partial template (like vars.html.twig), all these variables?
I’ve tried with all tags twig that influence in inheritance, like include, embed, block, use, etc, but no successfull results.
I think that inheritance vars between modules templates is not possible.