A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://developers.google.com/apps-script/reference/html/html-template below:

Class HtmlTemplate | Apps Script

Class HtmlTemplate

Stay organized with collections Save and categorize content based on your preferences.

HtmlTemplate

A template object for dynamically constructing HTML. For more information, see the guide to templates.

Methods Method Return type Brief description evaluate() HtmlOutput Evaluates this template and returns an HtmlOutput object. getCode() String Generates a string of JavaScript code, based on the template file, that can be evaluated. getCodeWithComments() String Generates a string of JavaScript code that can be evaluated, with each line of the code containing the original line from the template as a comment. getRawContent() String Returns the unprocessed content of this template. Detailed documentation evaluate()

Evaluates this template and returns an HtmlOutput object. Any properties set on this HtmlTemplate object will be in scope when evaluating. To debug errors in a template, examine the code using the getCode() method.

// A template which evaluates to whatever is bound to 'foo'.
const template = HtmlService.createTemplate('<?= foo ?>');
template.foo = 'Hello World!';
Logger.log(template.evaluate().getContent());  // will log 'Hello World!'
Return

HtmlOutput — an HtmlOutput object

getCode()

Generates a string of JavaScript code, based on the template file, that can be evaluated. This method produces a string of JavaScript code based on the template file. Calling eval(<code>) will return a new HtmlOutput object with the content of the template after running all embedded server scripts. The generated code is intended to be human-readable, and so if you need to debug a template you can call Logger.log(<code>) to see what was produced.

Evaluating this code will implicitly bind in all variables in the current scope. In general, it's preferable to use the evaluate() method, which takes explicit bindings.

const template = HtmlService.createTemplate(
    '<b>The time is &lt;?= new Date() ?&gt;</b>',
);
Logger.log(template.getCode());
Return

String — a string based on the template, which can be evaluated

getRawContent()

Returns the unprocessed content of this template.

const template = HtmlService.createTemplate(
    '<b>The time is &lt;?= new Date() ?&gt;</b>',
);
Logger.log(template.getRawContent());
Return

String — the template's raw content

Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2024-12-03 UTC.

[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2024-12-03 UTC."],[[["`HtmlTemplate` helps you dynamically build HTML content within Apps Script."],["It provides methods like `evaluate()` to render HTML with data, and `getCode()` to generate the underlying JavaScript."],["You can use `getRawContent()` to access the original template content and `getCodeWithComments()` for debugging purposes."],["The rendered output can be further handled using the `HtmlOutput` object."]]],[]]


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4