Reputation: 85
I giving a first shot at HTML templating with Google AppsScript and have had a pretty decent experience so far. My problem is that URLs are not being processed (replaced by "false")
My code.gs looks like this :
var section = HtmlService
.createTemplateFromFile('section')
.evaluate()
.setSandboxMode(HtmlService.SandboxMode.IFRAME);
Logger.log(section.getContent());
and my html (section.html) :
<?
var section = [
{title: "foo",
paragraph: "bar",
url: "https://www.youtube.com/v=foobar"},
{title: "foo2",
paragraph: "bar2",
url: "https://www.youtube.com/v=foobar2"}];
for (var x in section) { ?>
<h1><?= section[x].title ?> </h1>
<p><?= section[x].paragraph ?> </p>
<a href="<?= section[x].url ?>"> link </a>
<? } ?>
And the result of this (the log) :
<h1>foo </h1>
<p>bar</p>
<a href="false"> link </a>
<h1>foo2 </h1>
<p>bar2</p>
<a href="false"> link </a>
The same occurs for img' urls as well so I'm guessing there is a security notion here that I might be overlooking... Do you have an idea how to fix it?
thanks!
Upvotes: 1
Views: 376
Reputation: 85
Nevermind...
The issue was just improper force-printing syntax...
So if that happens to you in the future, your templating tags should look like this :
<?!= .... =>
and not
<? .... ?>
nor (that was my mistake) :
<?=! .... ?>
Upvotes: 2