Home > database >  appscript htmlservice template query: updating href with data attached to an html template
appscript htmlservice template query: updating href with data attached to an html template

Time:11-15

 <?= data["message"] ?>. <br />
                                    <br />
                                    <!-- <?= 
                                    $documentFolder = \".data["documentFolder"].\";
                                    ?> -->
                                    <br>
          <a href=""

data["message"] evaluates fine But I'm having trouble updating the href between the quotes; I've tried escape characters, building the html element separately but that is not evaluated any ideas/suggestions welcome

CodePudding user response:

Building an anchor tag href with templated html

GS:

I just made a dialog to test it

function myfunk() {
   let t = HtmlService.createTemplateFromFile('ah1');
   t.data ={url:"https://google.com",label:"Link"};
   let ui = t.evaluate();
   Logger.log(ui);
   SpreadsheetApp.getUi().showModelessDialog(ui,'Modeless Dialog');
 }

HTML:

<!DOCTYPE html>
<html>
  <head>
    <base target="_top">
  </head>
  <body>
    <div>
     <a href="<?= data.url ?>" target="_blank"><?=data.label?></a>
    </div>
  </body>
</html>

Dialog:

enter image description here

  • Related