Skip line if undefined.

Sherwood Botsford <[email protected]> Sat, 31 Mar 2018 12:08:18 -0600
Newsgroups gmane.comp.lang.perl.modules.template-toolkit
Message-ID <CAOX=2F_Jwx-UUswNocZOEnFRH2xgZaFSqQGpeuhXrO+eZ=1rVg@mail.gmail.com>
--===============4705234349664319314==
Content-Type: multipart/alternative; boundary="94eb2c1c09763ab1940568b940fd"

--94eb2c1c09763ab1940568b940fd
Content-Type: text/plain; charset="UTF-8"

My web pages start with something like this:

[% PROCESS header.inc
Title = "Shelterbelt Production"
Desc = "Walk through on the economics of producing large numbers of medium
size trees for use in shelterbelt plantings."
FBimage="$base/Images/AdPix/Trade_Show/2013-06-27_20-32-32.jpg"

%]

Note the FBimage variable.

In Header.inc

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">

[% USE String %]
[% USE MultiMarkdown %]

[% pathchunks = template.name.split('/') ;
chunks = pathchunks.max
pathchunks.$chunks = pathchunks.last.replace('.tt2','.html');
CurWebPage = '/' _ template.name.replace('.tt2','.html');

    CurWebLink = base _ CurWebPage
%]


<head>
  <meta http-equiv="Content-type" content="text/html;charset=UTF-8" />
  <meta content="text/html; charset=UTF-8" http-equiv="content-type" />
$ExtraMetaContent
  <title>$Title</title>
  <base href="$base" />
  <meta name="description" content="$Desc" />

  <meta property="og:site_name" content="Tree Farm for Sale"/>
    <meta property="og:type" content="article"/>
  <meta property="og:image" content="$FBimage"/>
  <meta property="og:title" content="$Title"/>
  <meta property="og:url" content="$CurWebLink "/>
  <link rel="shortcut icon" href="/favicon.ico"
type="image/vnd.microsoft.icon" />
  <link type="text/css" href="/2col.css" rel="stylesheet" />
  <link rel="canonical" href=$CurWebLink />
  <meta name="viewport" content="width=device-width, initial-scale=1" />


Ok.

The problem occurs with the open graph FBimage tag.  If I don't define it
in my header later then facebook uses no image at all when shared.
Otherwise it will default to the first image on the page.

How do I modify Header.inc so that it doesn't put in the line

 <meta property="og:image" content="$FBimage"/>

if FBimage isn't defined in the calling template?



Regards

Sherwood

--94eb2c1c09763ab1940568b940fd
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><div class=3D"gmail_default" style=3D"font-family:&quot;ti=
mes new roman&quot;,serif"><br clear=3D"all"></div><div class=3D"gmail_defa=
ult" style=3D"font-family:&quot;times new roman&quot;,serif">My web pages s=
tart with something like this:=C2=A0</div><div class=3D"gmail_default" styl=
e=3D"font-family:&quot;times new roman&quot;,serif"><br></div><div class=3D=
"gmail_default"><div class=3D"gmail_default"><div class=3D"gmail_default"><=
font face=3D"times new roman, serif">[% PROCESS header.inc=C2=A0</font></di=
v><div class=3D"gmail_default"><font face=3D"times new roman, serif"><span =
style=3D"white-space:pre">	</span>Title =3D &quot;Shelterbelt Production&qu=
ot;=C2=A0</font></div><div class=3D"gmail_default"><font face=3D"times new =
roman, serif"><span style=3D"white-space:pre">	</span>Desc =3D &quot;Walk t=
hrough on the economics of producing large numbers of medium size trees for=
 use in shelterbelt plantings.&quot;</font></div><div class=3D"gmail_defaul=
t"><font face=3D"times new roman, serif"><span style=3D"white-space:pre">	<=
/span>FBimage=3D&quot;$base/Images/AdPix/Trade_Show/2013-06-27_20-32-32.jpg=
&quot;</font></div><div class=3D"gmail_default"><font face=3D"times new rom=
an, serif"><br></font></div><div class=3D"gmail_default"><font face=3D"time=
s new roman, serif">%]</font></div><div class=3D"gmail_default"><font face=
=3D"times new roman, serif"><br></font></div><div class=3D"gmail_default"><=
font face=3D"times new roman, serif">Note the FBimage variable.</font></div=
><div class=3D"gmail_default"><font face=3D"times new roman, serif"><br></f=
ont></div><div class=3D"gmail_default"><font face=3D"times new roman, serif=
">In Header.inc</font></div><div class=3D"gmail_default"><font face=3D"time=
s new roman, serif"><br></font></div><div class=3D"gmail_default"><font fac=
e=3D"times new roman, serif"><div class=3D"gmail_default">&lt;?xml version=
=3D&quot;1.0&quot; encoding=3D&quot;utf-8&quot;?&gt;</div><div class=3D"gma=
il_default">&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Strict//EN=
&quot;</div><div class=3D"gmail_default">=C2=A0 =C2=A0 =C2=A0 =C2=A0 &quot;=
<a href=3D"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">http://www.w3=
.org/TR/xhtml1/DTD/xhtml1-strict.dtd</a>&quot;&gt;</div><div class=3D"gmail=
_default">&lt;html xmlns=3D&quot;<a href=3D"http://www.w3.org/1999/xhtml">h=
ttp://www.w3.org/1999/xhtml</a>&quot; xml:lang=3D&quot;en&quot; lang=3D&quo=
t;en&quot;&gt;</div><div class=3D"gmail_default"><br></div><div class=3D"gm=
ail_default">[% USE String %]</div><div class=3D"gmail_default">[% USE Mult=
iMarkdown %]</div><div class=3D"gmail_default"><br></div><div class=3D"gmai=
l_default">[% pathchunks =3D template.name.split(&#39;/&#39;) ;</div><div c=
lass=3D"gmail_default"><span style=3D"white-space:pre">	</span>chunks =3D p=
athchunks.max</div><div class=3D"gmail_default"><span style=3D"white-space:=
pre">	</span>pathchunks.$chunks =3D pathchunks.last.replace(&#39;.tt2&#39;,=
&#39;.html&#39;);</div><div class=3D"gmail_default"><span style=3D"white-sp=
ace:pre">	</span>CurWebPage =3D &#39;/&#39; _ template.name.replace(&#39;.t=
t2&#39;,&#39;.html&#39;);</div><div class=3D"gmail_default">=C2=A0 =C2=A0=
=C2=A0</div><div class=3D"gmail_default">=C2=A0 =C2=A0 CurWebLink =3D base =
_ CurWebPage</div><div class=3D"gmail_default">%]</div><div class=3D"gmail_=
default"><br></div><div class=3D"gmail_default">=C2=A0 =C2=A0</div><div cla=
ss=3D"gmail_default">&lt;head&gt;</div><div class=3D"gmail_default">=C2=A0 =
&lt;meta http-equiv=3D&quot;Content-type&quot; content=3D&quot;text/html;ch=
arset=3DUTF-8&quot; /&gt;</div><div class=3D"gmail_default">=C2=A0 &lt;meta=
 content=3D&quot;text/html; charset=3DUTF-8&quot; http-equiv=3D&quot;conten=
t-type&quot; /&gt;</div><div class=3D"gmail_default"><span style=3D"white-s=
pace:pre">	</span>$ExtraMetaContent</div><div class=3D"gmail_default">=C2=
=A0 &lt;title&gt;$Title&lt;/title&gt;</div><div class=3D"gmail_default">=C2=
=A0 &lt;base href=3D&quot;$base&quot; /&gt;</div><div class=3D"gmail_defaul=
t">=C2=A0 &lt;meta name=3D&quot;description&quot; content=3D&quot;$Desc&quo=
t; /&gt;</div><div class=3D"gmail_default">=C2=A0</div><div class=3D"gmail_=
default">=C2=A0 &lt;meta property=3D&quot;og:site_name&quot; content=3D&quo=
t;Tree Farm for Sale&quot;/&gt;</div><div class=3D"gmail_default">=C2=A0 =
=C2=A0 &lt;meta property=3D&quot;og:type&quot; content=3D&quot;article&quot=
;/&gt;</div><div class=3D"gmail_default">=C2=A0 &lt;meta property=3D&quot;o=
g:image&quot; content=3D&quot;$FBimage&quot;/&gt;</div><div class=3D"gmail_=
default">=C2=A0 &lt;meta property=3D&quot;og:title&quot; content=3D&quot;$T=
itle&quot;/&gt;</div><div class=3D"gmail_default">=C2=A0 &lt;meta property=
=3D&quot;og:url&quot; content=3D&quot;$CurWebLink &quot;/&gt;</div><div cla=
ss=3D"gmail_default">=C2=A0 &lt;link rel=3D&quot;shortcut icon&quot; href=
=3D&quot;/favicon.ico&quot; type=3D&quot;image/vnd.microsoft.icon&quot; /&g=
t;</div><div class=3D"gmail_default">=C2=A0 &lt;link type=3D&quot;text/css&=
quot; href=3D&quot;/2col.css&quot; rel=3D&quot;stylesheet&quot; /&gt;</div>=
<div class=3D"gmail_default">=C2=A0 &lt;link rel=3D&quot;canonical&quot; hr=
ef=3D$CurWebLink /&gt;</div><div class=3D"gmail_default">=C2=A0 &lt;meta na=
me=3D&quot;viewport&quot; content=3D&quot;width=3Ddevice-width, initial-sca=
le=3D1&quot; /&gt;</div><div class=3D"gmail_default"><br></div><div class=
=3D"gmail_default"><br></div><div class=3D"gmail_default">Ok.=C2=A0=C2=A0<b=
r><br>The problem occurs with the open graph FBimage tag.=C2=A0 If I don&#3=
9;t define it in my header later then facebook uses no image at all when sh=
ared.=C2=A0 Otherwise it will default to the first image on the page.</div>=
<div class=3D"gmail_default"><br></div><div class=3D"gmail_default">How do =
I modify Header.inc so that it doesn&#39;t put in the line=C2=A0</div><div =
class=3D"gmail_default"><br></div><div class=3D"gmail_default"><span style=
=3D"color:rgb(34,34,34);font-family:&quot;times new roman&quot;,serif;font-=
size:small;font-style:normal;font-variant-ligatures:normal;font-variant-cap=
s:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent=
:0px;text-transform:none;white-space:normal;word-spacing:0px;background-col=
or:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:ini=
tial;float:none;display:inline"><span>=C2=A0</span>&lt;meta property=3D&quo=
t;og:image&quot; content=3D&quot;$FBimage&quot;/&gt;</span><br></div><div c=
lass=3D"gmail_default"><span style=3D"color:rgb(34,34,34);font-family:&quot=
;times new roman&quot;,serif;font-size:small;font-style:normal;font-variant=
-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:n=
ormal;text-align:start;text-indent:0px;text-transform:none;white-space:norm=
al;word-spacing:0px;background-color:rgb(255,255,255);text-decoration-style=
:initial;text-decoration-color:initial;float:none;display:inline"><br></spa=
n></div><div class=3D"gmail_default"><span style=3D"color:rgb(34,34,34);fon=
t-family:&quot;times new roman&quot;,serif;font-size:small;font-style:norma=
l;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;le=
tter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;wh=
ite-space:normal;word-spacing:0px;background-color:rgb(255,255,255);text-de=
coration-style:initial;text-decoration-color:initial;float:none;display:inl=
ine">if FBimage isn&#39;t defined in the calling template?</span></div><div=
 class=3D"gmail_default"><br></div></font></div></div></div><div class=3D"g=
mail_default" style=3D"font-family:&quot;times new roman&quot;,serif"><br><=
/div><div class=3D"gmail_default" style=3D"font-family:&quot;times new roma=
n&quot;,serif"><br></div><div><div class=3D"gmail_signature"><div dir=3D"lt=
r"><div><div dir=3D"ltr"><div><div dir=3D"ltr"><div>Regards</div><div><br><=
/div><div>Sherwood<br><br></div></div></div></div></div></div></div></div>
</div>

--94eb2c1c09763ab1940568b940fd--


--===============4705234349664319314==
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: base64
Content-Disposition: inline

X19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX18KdGVtcGxhdGVz
IG1haWxpbmcgbGlzdAp0ZW1wbGF0ZXNAbGlzdHMub3Vyc2hhY2suY29tCmh0dHBzOi8vbGlzdHMu
b3Vyc2hhY2suY29tL21haWxtYW4vbGlzdGluZm8vdGVtcGxhdGVzCg==

--===============4705234349664319314==--