SectionKnowledge BaseTopicTemplatesDepthComplete reference
Quick Answers
  • Template variable syntax and delimiter formats
  • Conditional blocks for threshold-based display
  • Format specifiers for decimal places and unit suffixes
  • Multi-language template output configuration
  • Debugging missing or literal variable text in output

Templates are where raw station data becomes a readable web page. GraphWeather’s template engine replaces variable placeholders with live data at each publish cycle, generating static HTML that gets uploaded via FTP. Understanding the variable system, conditional logic, and format specifiers is essential for building custom station pages that display the information you care about. This guide covers the template system in depth, building on the foundational patterns in Publishing Fundamentals.

Variable Syntax

Template variables use delimiter-wrapped names that the engine recognises and replaces. Depending on the GraphWeather version, the syntax may use angle-bracket-percent or double-curly-brace notation:

<!-- Angle-bracket style -->
<span>Temperature: <%outdoor_temp%> °C</span>

<!-- Curly-brace style -->
<span>Temperature: {{outdoor_temp}} °C</span>

Both styles work the same way. The engine scans the template file, finds delimited tokens, looks up the current value, and writes the result. If a variable name is not recognised, the behaviour depends on configuration: some setups leave the token as-is (useful for debugging), while others replace it with an empty string or a placeholder like “N/A”.

Core Variables

VariableDescriptionTypical Unit
outdoor_tempCurrent outdoor temperature°C or °F
outdoor_humidityRelative humidity%
indoor_tempIndoor temperature (console sensor)°C or °F
barometerSea-level-corrected barometric pressurehPa or inHg
wind_speedCurrent wind speedkm/h, mph, m/s, knots
wind_gustHighest gust in current periodSame as wind_speed
wind_directionWind direction in degrees0–360°
wind_dir_textCardinal direction textN, NNE, NE…
rain_todayRainfall since midnightmm or in
rain_rateCurrent rainfall ratemm/h or in/h
dewpointCalculated dew point°C or °F
windchillWind chill factor°C or °F
heat_indexHeat index°C or °F
last_updateTimestamp of latest readingConfigurable format
sunrise / sunsetToday’s sunrise/sunset timesHH:MM

Conditional Blocks

Templates support conditional logic for threshold-based display. For example, showing a frost warning when temperature drops below zero:

<%if outdoor_temp < 0%>
  <div class="alert">⚠️ Frost warning: <%outdoor_temp%> °C</div>
<%endif%>

Conditions can use comparison operators (<, >, ==, !=) and combine with AND / OR logic. Nested conditions are supported but should be used sparingly — deeply nested templates become difficult to maintain.

Format Specifiers

Control decimal places and formatting with specifiers appended to variable names:

Multi-Language Output

For stations serving audiences in multiple languages, GraphWeather supports generating multiple output files from separate templates. Configure each template with language-specific labels and upload them to separate directories or filenames:

/weather/index_en.html  ← English template
/weather/index_fr.html  ← French template

Variable values (numbers, dates) can be formatted according to locale settings. Text labels are part of the template HTML, so each language file contains its own labels.

Troubleshooting Matrix

SymptomLikely CauseFix
Variable shows as literal textWrong delimiter or typo in variable nameCheck delimiter style matches your version; verify variable name spelling
Variable shows blank/emptyData source disconnected or variable not populatedCheck station connection; verify the variable is supported by your station type
Encoding issues (garbled characters)Template file saved in wrong encodingSave template as UTF-8; add <meta charset="utf-8"> to HTML head
Conditional block always showsComparison logic error or variable type mismatchVerify the comparison operator and that the variable returns a number, not a string
Old data displaying despite new readingsBrowser caching or CDN cacheSee Image Refresh and Caching

FAQ

Can I use JavaScript in templates?
Yes. GraphWeather generates static HTML, so you can include any JavaScript in your template. The variable replacement happens server-side before upload. JavaScript runs in the browser after the page loads.
How do I embed graphs in templates?
Reference graph image paths in standard <img> tags. Add a cache-busting query parameter using the last_update or publish_timestamp variable to prevent stale images.
Can I use CSS frameworks like Bootstrap?
Absolutely. Your template is a regular HTML file — include any CSS or JavaScript framework you like. Just ensure external resources are either self-hosted or served from a CDN you trust for uptime.
What happens if the station is offline?
Variables will either show the last known value (if caching is enabled) or display as blank/N/A depending on configuration. The template still generates and uploads, so visitors see a page — just with stale data.