Skip to content

Instantly share code, notes, and snippets.

@arpeggio068
Created October 24, 2022 13:22
Show Gist options
  • Select an option

  • Save arpeggio068/e167d41e08717944736513483525fb1d to your computer and use it in GitHub Desktop.

Select an option

Save arpeggio068/e167d41e08717944736513483525fb1d to your computer and use it in GitHub Desktop.
Frontend Library
//// start Frontend Library code.gs ////////////////////////////////////////////////////////////
function includeLibrary(){
return HtmlService.createHtmlOutputFromFile("library-js").getContent();
}
//// end Frontend Library code.gs //////////////////////////////////////////////////////////////
//// start Frontend Library library-js.html ///////////////////////////////////////////////////
<script>
function testAlert(){
alert("This is frontend library")
}
</script>
//// end Frontend Library library-js.html ///////////////////////////////////////////////////
//// start testLib_V1 code.gs ////////////////////////////////////////////////////
function doGet(e){
return HtmlService.createTemplateFromFile("index").evaluate()
.setTitle("home")
.addMetaTag('viewport', 'width=device-width, initial-scale=1')
.setXFrameOptionsMode(HtmlService.XFrameOptionsMode.ALLOWALL);
}
function includeLibrary(){
Logger.log(fl.includeLibrary())
return fl.includeLibrary()
}
//// end testLib_V1 code.gs ////////////////////////////////////////////////////
//// start testLib_V1 index.html ////////////////////////////////////////////////////
<!DOCTYPE html>
<html>
<head>
<base target="_top">
</head>
<body>
<button onclick="testAlert()">Click</button>
<?!=includeLibrary()?>
</body>
</html>
//// end testLib_V1 index.html ////////////////////////////////////////////////////
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment