Use Twig Custom Set Variables From an Include

Viewed 20340

I'm trying to include a twig file with a bunch of custom set variables and then use the variables in the multiple other template files. Similar to how including a PHP file works.

I don't seem to have access to the variables set inside the include in my index file.

Is there any way to do this?

Sample Code *Edited

Included File:

{# variables.html #}
{% set width = "100" %}
{% set height = "250" %}

Template File:

{# index.html #} 
{% include 'variables.html' %}
{{ width }}
{{ height }}

Expected Outcome:

100 250

Actual Outcome:

// Nothing gets output
3 Answers
Related