0

I am trying to include lab_mois.html into lab_temp.html. But when I do this inclusion, lab_temp.html doesn't show (just) the variable (mois) of lab_mois.html.

This is lab_mois.html, whith variable mois:

<html>
</head>
  <body>
    <div class="container">
      <div class="row">
        <div class="two-third column" style="margin-top: 5%">
            <h1>Moisture in Rockwool: {{"{0:0.1f}".format(mois)}}%</h1>
        </div>
      </div>
    </div>
  </body>
</html>

This is the output of lab_mois.html by itself

enter image description here

This is lab_temp.html with {% include 'lab_mois.html' %} :

<html>
  </head>
    <body>
      <div class="container">
        <div class="row">
          <div class="two-third column" style="margin-top: 5%">
              <h2>LivingGreenCity - Real time conditions</h2>
              <p>60 Park Lane, Flat 36, London, W1K 1QE, UK</p>
              <h3>                                      </h3>
              <h1>Air Temperature: {{"{0:0.1f}".format(temp) }}°C</h1>
              <h1>Air Humidity: {{"{0:0.1f}".format(hum)}}%</h1>
              <h1>Humidity in Rockwool: {{"{0:0.1f}".format(hum)}}%</h1>
              {% include 'lab_mois.html' %}
              <p>This page refreshes every 10 seconds</p>
          </div>
        </div>
    </body>
  </html>

but the output is this one (notice that Moisture in Rockwool has no value):

enter image description here

How can I make the value of mois appear in lab_temp.html?

DavidG
  • 24,279
  • 14
  • 89
  • 82
e-Long
  • 1
  • Can use the `with syntax` as described here: http://stackoverflow.com/questions/9404990/how-to-pass-selected-named-arguments-to-jinja2s-include-context – reptilicus Nov 23 '16 at 17:56
  • 1
    But it should "just work". Included templates should have access to the same context/variables as the parent template – reptilicus Nov 23 '16 at 17:58
  • 1
    @reptilicus right? it should work. I don't know why it doesn't. – e-Long Nov 24 '16 at 13:47

0 Answers0