jsmash
jsmash

Reputation: 13

How to reference HtmlTemplate variables in javascript in Google Apps Script

I'm trying to reference a variable I've set in my html template inside the javascript section of my HTML file.

Using the Google example code

function doGet() {
  var t = HtmlService.createTemplateFromFile('Index');
  t.data = SpreadsheetApp
      .openById('1234567890abcdefghijklmnopqrstuvwxyz')
      .getActiveSheet()
      .getDataRange()
      .getValues();
  return t.evaluate();
}

I could reference t.data in my HTML with

<? data ?>

But how do I reference the same variable in javascript?

Upvotes: 1

Views: 332

Answers (1)

TheMaster
TheMaster

Reputation: 50445

You could use

<script>
  const data = <? data ?>
</script>

Upvotes: 1

Related Questions