Include $almanac.moonphase in an <img path

41 views
Skip to first unread message

Den

unread,
Jun 24, 2024, 5:25:12 PM (10 days ago) Jun 24
to weewx-user
I have named moon phase .jpg images in the folder weather/moon that match the $almanac.moonphase names.
I am trying to display the image based on the $ variable. Here is the html in the tmpl file:
<img src="weather/moon/ $almanac.moonphase.jpg">

I have tried all kinds of spaces, quotes, single quotes ... without getting the image to display. 
For example:
<img src="weather/moon/" $almanac.moonphase".jpg">

If I enter the line without the $ variable it works:
<img src="weather/moon/Waning gibbous.jpg">

Thanks for reading this and hopefully filling me in with the answer.
Den

W2DEN

unread,
Jun 24, 2024, 5:30:16 PM (10 days ago) Jun 24
to 'Den' via weewx-user

I found the answer, embed the variable in braces{}

<img src="weather/moon/{$almanac.moonphase}.jpg"/>

It is more of an HTML solution than anything else.

Den

--
You received this message because you are subscribed to a topic in the Google Groups "weewx-user" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/weewx-user/E_PBXItrogc/unsubscribe.
To unsubscribe from this group and all its topics, send an email to weewx-user+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/weewx-user/6098a4c6-e8db-4636-89c5-11fc2de9833en%40googlegroups.com.
Message has been deleted

W2DEN

unread,
Jun 24, 2024, 5:35:28 PM (10 days ago) Jun 24
to 'W2DEN' via weewx-user

Of course I'd screw up the answer....

this works....(not real sure why but it does.)

<img src="weather/moon/${almanac.moonphase}.jpg"/>

results in:

<img src="weather/moon/Waning gibbous.jpg"/>

Den

Graham Eddy

unread,
Jun 24, 2024, 11:45:20 PM (9 days ago) Jun 24
to WeeWX User
it removes ambiguity - distinguish ${almanac}.moonphase.jpg from ${almanac.moonphase}.jpg from ${almanac.moonphase.jpg}
⊣GE⊢
Reply all
Reply to author
Forward
0 new messages