<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Way to insert a HTML link in var]]></title><description><![CDATA[<p dir="auto">Hi everybody and first of all, sorry for my poor words choice, i’m not english native.</p>
<p dir="auto">On my MM I Show pictures from a HTML link in Compliments module. In order to make my code prettier, i’m looking for a way to replace the HTML link by a var as I show the same picture in several modules compliments. My issue is that i don’t find the right syntax to make this work…</p>
<p dir="auto">In other words, i want to replace</p>
<p dir="auto">{</p>
<p dir="auto">Module compliment 1  :<br />
Image = https : //www…</p>
<p dir="auto">Module compliment 2  :<br />
Image = https : //www…</p>
<p dir="auto">}</p>
<p dir="auto">by</p>
<p dir="auto">{<br />
Img = https://</p>
<p dir="auto">Module compliment 1  :<br />
Img</p>
<p dir="auto">Module compliment 2  :<br />
Img</p>
<p dir="auto">}</p>
<p dir="auto">Thanks a lot if you’re smart enough to help me finding an answer !</p>
]]></description><link>https://forum.magicmirror.builders/topic/17339/way-to-insert-a-html-link-in-var</link><generator>RSS for Node</generator><lastBuildDate>Sun, 07 Jun 2026 11:10:34 GMT</lastBuildDate><atom:link href="https://forum.magicmirror.builders/topic/17339.rss" rel="self" type="application/rss+xml"/><pubDate>Wed, 02 Nov 2022 12:54:36 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Way to insert a HTML link in var on Fri, 04 Nov 2022 08:26:32 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/tom_labhidouille" aria-label="Profile: Tom_LabHIdouille">@<bdi>Tom_LabHIdouille</bdi></a> I’m not familiar with compliments, but can’t you create a locale html-file at the modules folder with the link to the picture you prefer and add the name of the html at all the compliments-module(s).<br />
The benefit would be only to change the locale file and all the compliments-modules should show your picture.</p>
]]></description><link>https://forum.magicmirror.builders/post/105665</link><guid isPermaLink="true">https://forum.magicmirror.builders/post/105665</guid><dc:creator><![CDATA[thgmirror]]></dc:creator><pubDate>Fri, 04 Nov 2022 08:26:32 GMT</pubDate></item><item><title><![CDATA[Reply to Way to insert a HTML link in var on Fri, 04 Nov 2022 02:24:50 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/tom_labhidouille" aria-label="Profile: Tom_LabHIdouille">@<bdi>Tom_LabHIdouille</bdi></a> you won’t be able to share the variable across module instances</p>
]]></description><link>https://forum.magicmirror.builders/post/105664</link><guid isPermaLink="true">https://forum.magicmirror.builders/post/105664</guid><dc:creator><![CDATA[sdetweil]]></dc:creator><pubDate>Fri, 04 Nov 2022 02:24:50 GMT</pubDate></item><item><title><![CDATA[Reply to Way to insert a HTML link in var on Thu, 03 Nov 2022 03:46:14 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/tom_labhidouille" aria-label="Profile: Tom_LabHIdouille">@<bdi>Tom_LabHIdouille</bdi></a> there is no way to do it currently with the existing code.</p>
<p dir="auto">its easy to create variables</p>
<pre><code>    module: "compliments",
    config: {
          some_var:"http:......."
           compliments:{..... }
    }
</code></pre>
<p dir="auto">the problem is using them …  thru config…</p>
<p dir="auto">but a couple lines of code in getDom()   could make this functional</p>
<pre><code>            compliements:{
                 anytime: [   "whatever", "var:some_var"]
</code></pre>
<p dir="auto">and in getDom</p>
<pre><code>               // existing code (small change const to let) 
		let complimentText. = this.randomC ompliment();
               // new code 
              if(complimentText.startsWith("var:")
                   complimentText= this.config[complimentText.split(':')[1&rsqb;&rsqb;
</code></pre>
<p dir="auto">now you would have to do more if the content is html (img src=“var:…”)</p>
<pre><code>                // loop thru the html content
                let lastindex=0
                while(true){
                       let index = complimentText.indexOf('"var:',lastindex)
                       if (index&gt;=0){
                              lastindex=index
                           // some code to extract the var: string  and it variable
                                //using indexOf and slice (note the previous found the " in front of var:   
                           // get its variable value from config
                          // replace the string, and continue from the previous index (lastindex) 
                         }
                         else break;  // out of while loop
                   }
</code></pre>
]]></description><link>https://forum.magicmirror.builders/post/105656</link><guid isPermaLink="true">https://forum.magicmirror.builders/post/105656</guid><dc:creator><![CDATA[sdetweil]]></dc:creator><pubDate>Thu, 03 Nov 2022 03:46:14 GMT</pubDate></item></channel></rss>