Andrew
Andrew

Reputation: 429

Google Script Short Tags displaying on webpage

I am trying to build a google web app that will need to have multiple pages. I found Mogsdad's solution to that problem, and am trying to implement that. However, the short tag is displaying on my page, as opposed to running in the background. For simplicity purposes, here's a really short example of what I'm seeing.

testfile.html

<html>
  <body>
    <h1>Source = testfile.html</h1>
    <?var url = getScriptUrl();?><a href='<?=url?>?page=my2'> <input type='button' name='button' value='my2.html'></a>
  </body>
</html>

And here is an image of the webpage that is generated from that html.

enter image description here

As you can see, the text inside the short open/close tags is actually displaying, as opposed to being run. I've done a lot of searching on this, and found a number of things related to php (which I know uses a similar tag to do the same thing), and making sure the php.ini is set correctly. But I haven't seen anything to help when it's google apps script where the short open tag is displaying. Anyone else run into this? Any thoughts on where the issue here is?

Upvotes: 1

Views: 124

Answers (1)

Alan Wells
Alan Wells

Reputation: 31300

Your doGet() function needs to look like this:

function doGet() {
  return HtmlService
      .createTemplateFromFile('testfile')
      .evaluate();
}

You don't need the first scriptlet at all. You can change the scriptlet in the href attribute to:

<a href="<?= getScriptUrl() ?>?page=my2"> <input type='button' name='button' value='my2.html'></a>

You can see the documentation at:

Apps Script documentation

Upvotes: 1

Related Questions