问题
I'm learning google apps script, and in this tutorial, I saw some weird looking syntax: <? /* JS code */ ?>
and <?= /* JS code */ ?>
<!DOCTYPE html>
<html>
<head>
<base target="_top">
<title>Message Display Test</title>
<link rel="stylesheet" href="https://ssl.gstatic.com/docs/script/css/add-ons1.css">
</head>
<body style="padding:3em;">
<h1>Messages</h1>
<ul>
<? for(var m=0;m<messages.length;m++){ ?>
<li><?= messages[m].getSubject() ?></li>
<p><?= messages[m].getPlainBody() ?></p>
<? } ?>
</ul>
</body>
</html>
I can kind of understand what is going on, but I'm still confused. I've never seen these while learning HTML. How does this compare to script tags?
回答1:
In Google Apps Script <? . . .?>
are called standar scriptlets, <?= . . . ?>
are printed scriptlets and <?!= . . . ?>
are force printing scriplets. They are used in Google Apps Script HTML Service templated HTML.
Resource
- https://developers.google.com/apps-script/guides/html/templates
Related
- How to use scriptlets in HTMLOutput in Google Apps Script
- What does <?!= mean in Google Apps Script?
回答2:
The question mark is used for PHP and is incorporated into html to work. It is another programming language related to web design. PHP is mainly used to make more advanced form system.
来源:https://stackoverflow.com/questions/63571391/html-tag-beginning-with-question-mark