1

I have a function in code.gs:

function include(filename) {
  return HtmlService.createHtmlOutputFromFile(filename).getContent();
}

function onOpen() {
  var ui = SpreadsheetApp.getUi();
  ui.createMenu('Sample Title')
      .addItem('Sidebar Menu','showSampleSidebar')
      .addToUi();
}

function showSampleSidebar() {
  var html = HtmlService.createHtmlOutputFromFile('SampleHTML.html')
      .setTitle('Sample HTML')
      .setWidth(300);
  SpreadsheetApp.getUi()
      .showSidebar(html);
}


SampleHTML.html has the below code

<!DOCTYPE html>
<html>
  <head>
    <base target="_top">
    <?!= include("JavaScript"); ?>
  </head>
  <body style="padding:10px;">
    <div>
      <?!= include("AnotherSampleHTML"); ?>
    </div>
  </body>
</html>

JavaScript.html file has a sample JS code.

However, when sidebar is opened using Custom Menu, the sidebar is printing

<?!= include("JavaScript"); ?>
<?!= include("AnotherSampleHTML"); ?>

instead of getting the actual content from JavaScript.html and AnotherSampleHTML.html file.

What am I doing wrong?

megatower
  • 33
  • 6
  • `showSampleSidebar() { var html = HtmlService.createTemplate` HtmlOutput `FromFile('SampleHTML.html').evaluate()` See duplicates linked above. – TheMaster Sep 07 '20 at 11:01

0 Answers0