Service for returning HTML and other text content from a script.
Due to security considerations, scripts cannot directly return content to a browser. Instead,
they must sanitize the HTML so that it cannot perform malicious actions. See the description of
HtmlOutput
for what limitations this implies on what can be returned.
Properties
Property | Type | Description |
---|---|---|
SandboxMode | SandboxMode | An enum representing the sandbox modes that can be used for client-side HtmlService
scripts. |
Methods
Method | Return type | Brief description |
---|---|---|
createHtmlOutput() | HtmlOutput | Creates a new HtmlOutput object that can be returned from the script. |
createHtmlOutput(blob) | HtmlOutput | Creates a new HtmlOutput object from a BlobSource resource. |
createHtmlOutput(html) | HtmlOutput | Creates a new HtmlOutput object that can be returned from the script. |
createHtmlOutputFromFile(filename) | HtmlOutput | Creates a new HtmlOutput object from a file in the code editor. |
createTemplate(blob) | HtmlTemplate | Creates a new HtmlTemplate object from a BlobSource resource. |
createTemplate(html) | HtmlTemplate | Creates a new HtmlTemplate object that can be returned from the script. |
createTemplateFromFile(filename) | HtmlTemplate | Creates a new HtmlTemplate object from a file in the code editor. |
Detailed documentation
createHtmlOutput()
Creates a new HtmlOutput
object that can be returned from the script.
var output = HtmlService.createHtmlOutput();
Return
HtmlOutput
— the new HtmlOutput object
createHtmlOutput(blob)
Creates a new HtmlOutput
object from a BlobSource
resource.
function createFromBlob(blob) {
var output = HtmlService.createHtmlOutput(blob);
return output;
}
Parameters
Name | Type | Description |
---|---|---|
blob | BlobSource | the object to get HTML out of |
Return
HtmlOutput
— the new HtmlOutput
object
createHtmlOutput(html)
Creates a new HtmlOutput
object that can be returned from the script.
var output = HtmlService.createHtmlOutput('<b>Hello world!</b>');
Parameters
Name | Type | Description |
---|---|---|
html | String | the content to serve |
Return
HtmlOutput
— the new HtmlOutput object
createHtmlOutputFromFile(filename)
Creates a new HtmlOutput
object from a file in the code editor.
var output = HtmlService.createHtmlOutputFromFile('myPage');
Parameters
Name | Type | Description |
---|---|---|
filename | String | the name of the file to use |
Return
HtmlOutput
— the new HtmlOutput
object
createTemplate(blob)
Creates a new HtmlTemplate
object from a BlobSource
resource.
function createFromBlob(blob) {
var template = HtmlService.createTemplate(blob);
return output;
}
Parameters
Name | Type | Description |
---|---|---|
blob | BlobSource | the object to get HTML out of |
Return
HtmlTemplate
— the new HtmlTemplate
object
createTemplate(html)
Creates a new HtmlTemplate
object that can be returned from the script.
var template = HtmlService.createTemplate('<b>The time is <?= new Date() ?></b>');
Parameters
Name | Type | Description |
---|---|---|
html | String | the content of the template |
Return
HtmlTemplate
— the new HtmlTemplate
object
createTemplateFromFile(filename)
Creates a new HtmlTemplate
object from a file in the code editor.
var template = HtmlService.createTemplateFromFile('myTemplate');
Parameters
Name | Type | Description |
---|---|---|
filename | String | the name of the file to use |
Return
HtmlTemplate
— the new HtmlTemplate
object