Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

372
Views
How do I include a file in HTML Google Apps Script?

I have attempted to create a new app, with app script, and I am attempting to use scriptlets but without success

function doGet() {
  return HtmlService.createHtmlOutputFromFile('index');
}

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

but nothing to do when verifying deployment doesn't work

<?!=include('Stylesheet'); ?>

please, help me!

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

In your situation, if <?!=include('Stylesheet'); ?> is included in index.html file, how about the following modification?

From:

function doGet() {
  return HtmlService.createHtmlOutputFromFile('index');
}

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

To:

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

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

Note:

  • If filename of include(filename) has the scriptlets, please modify as follows.

      function include(filename) {
        return HtmlService.createTemplateFromFile(filename).evaluate().getContent();
      }
    
  • In your script, it seems that Web Apps is used. In this case, when you modified the Google Apps Script, please modify the deployment as a new version. By this, the modified script is reflected in Web Apps. Please be careful this.

  • You can see the detail of this in the report of "Redeploying Web Apps without Changing URL of Web Apps for new IDE".

References:

  • createTemplateFromFile(filename)
  • createHtmlOutputFromFile(filename)
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!