Creates an HTML template from a string with scriptlets.
class HtmlService method .createTemplate()
HtmlService is the Apps Script service.
.createTemplate() is the method name you will see after a dot in your code.
What it does
Why it's used
- Inject sheet data into HTML with scriptlets.
- Render dynamic tables in a sidebar.
Common errors
- Forgetting parentheses on createTemplate. Write HtmlService.createTemplate(), not HtmlService.createTemplate or createTemplate by itself.
- Skipping dots between chained calls. Each step needs a dot, like HtmlService.createTemplate().
- Adding spaces where they do not belong. Write HtmlService.createTemplate(), not HtmlService .createTemplate(), HtmlService.createTemplate (), or HtmlService . createTemplate().
- Wrong capitalization. Use HtmlService and createTemplate, not htmlservice or createtemplate.
Explore
Related methods
-
.createTemplateFromFile()
Loads an HTML template from a file in the script project.
-
.evaluate()
Renders a template into final HTML output.
-
.createHtmlOutput()
Builds HTML output from a string for dialogs or sidebars.
-
.createHtmlOutputFromFile()
Loads HTML from a file in the script project.
-
.setTitle()
Sets the title shown on a dialog or sidebar.
More Apps Script
Better Sheets tutorials
No tagged tutorials yet. Fetch Apps Script from the harvest table and this page fills automatically.
Related blog posts
Written guides about HtmlService.createTemplate().
How to Use Google Sheets as a Website Database
Did you know you can use Google Apps Script to turn a Google Sheet into a free, auto-syncing database for your website? This guide shows you exactly how to set it up. You’ll prepare your spreadsheet, write a few lines of code and publish your site. Don’t worry if you’re not a developer, we’ll walk you through it. Why Use Google Sheets as a Database? For small projects, Google Sheets offers many advantages over traditional databases: * Free hosting and storage * Easy to edit data without...
Read post →Google Sheets Templates - Frequently Asked Questions(FAQ)
Google Sheets Templates are pre-designed Google Sheets for a specific use-case or a specific action. They can be designed for certain roles, or for different amounts of people to access them.
Read post →