0
votes

I'm experimenting with Google Apps Scripts webapps. I've just got sidebars working and they're very useful but when I try to do a simple webapp, the code shows in the app instead of being executed: enter image description here enter image description here enter image description here enter image description here

It must be something simple, but it's always simple when you know how.

Thanks for any help. ~

1

1 Answers

2
votes

You need to use the template service in the HtmlService.

https://developers.google.com/apps-script/guides/html/templates

code.gs

function doGet() {
  var html= HtmlService
      .createTemplateFromFile('Index');
      html.name = 'Bob';         
      return html.evaluate();
}

Index.html

<!DOCTYPE html>
<html>
  <head>
    <base target="_top">
  </head>
  <body>
    <b>Hi <?=name?>!</b>
  </body>
</html>