On pages like https://github.com/google/google-apps-script-samples/blob/master/simple_tasks/Page.html I see code bracketed as shown:
<?!= HtmlService.createHtmlOutputFromFile('JavaScript').getContent(); ?>
What does <?!=
to ?>
sequence mean? Does it translate to a direct call to Google Apps Script/Javascript on the server, in this case the global HtmlService object? Sort of like <?php
when using PHP?
This appears to be impossible to search for using the Goog. I tried various quoting/escaping techniques without success.
Those are called scriptlets, and as you mentioned, just like in PHP or other templating language, in Google Apps Script you can mix code and HTML when using HtmlTemplate method in the HtmlService, they will be evaluated at the server side, before the content is returned to the client, you can call functions defined in other .gs files, reference global variables, almost any code you can run inside a .gs file.
They are pretty well documented in the Official Developers Website, but in resume there are three types of scriplets:
<? ... ?>
: The code is executed without explicit output.<?= ... ?>
: The code runs and outputs the results using contextual escaping.<?!= ... ?>
: The code runs and outputs the results, but avoiding contextual escaping.The documentation has a simple example of how to separate HTML, CSS and JavaScript using Templated HTML.