1
votes

Hi GAS StackOverflow guides,

How do you append another HTML code/file after the initial doGet mentioned here? https://developers.google.com/apps-script/html_service#HTMLFiles

It says it can append using HtmlOutput class but no success with:

function doSomething() {
//append another HTML file
return HtmlService.createHtmlOutputFromFile('headers');
}

function doSomething2() {
//append another HTML file
return HtmlService.createHtmlOutputFromFile.append('headers');
}

Thanks.

1

1 Answers

4
votes

The append method on an HtmlOutput is for appending in the initial doGet function (if you are building up your HTML piece by piece). You can't use it to append more stuff later, but you can use the regular document.append() that you'd use in any other client-side JavaScript to do this. Something like this:

On the client

google.script.run.withSuccessHandler(function(x) { document.append(x); }).doSomething2()

On the server

function doSomething2() { return "the stuff I want to append"; }