Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8810745
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T03:11:34+00:00 2026-06-14T03:11:34+00:00

I am trying to prepare GAS code samples for embedding in Google Sites and

  • 0

I am trying to prepare GAS code samples for embedding in Google Sites and other web sites. I use the HtmlService.createHtmlOutput and HtmlService.createTemplateFromFile() and template.evaluate().getContent() to serve up an html version of the content of a google apps script. That all works fine as per this post.

Now I would like to prettify the code using prettyify.js. Im using the version embedded in caja and it almost works. However particular method names in the code being prettified throw an error from htmlservice.

Untaming of guest constructed objects objects unsupported. Expect a
function not a string : pln

Specifically, this text is successfully prettified,

function xisItHtml (e) {
  return ( e.parameter.hasOwnPropertu('template')) ;
}

whereas this throws an error

function xisItHtml (e) {
  return ( e.parameter.hasOwnProperty('template')) ;
}

It seems that specific methods (strange because none of this code is being executed, just prettified), cause caja sanitation to complain.

The code in the template is just this

$(document).ready(function () {
 // any jQueryness can happen here...
  try { 
    prettyPrint();
  }
  catch(err) {
    alert("failed prettification " + err);
  }
});

I’m pretty much stumped. any ideas?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T03:11:36+00:00Added an answer on June 14, 2026 at 3:11 am

    So it seems that there is a failure when you insert a prettified piece of text containing .toString() or .hasOwnProperty() into an htmloutput in GAS. I couldn’t find any other text that caused problems but there may be more. My hack was just to change the text before prettification and change it back later.

    $(document).ready(function () {
       // any jQueryness can happen here...
        var thingsThatScrewUp = [ 'toString', 'hasOwnProperty'],t;
    
        $('.pretty').each( function(i,elem) {
           var c = $(elem).text() ;
           // disguise
           for (var i = 0 ; i < thingsThatScrewUp.length ; i++ ) {
            c = c.replace(new RegExp("." + thingsThatScrewUp[i], 'g'),".sandw_" + i + "_ch");
           }
           try {
             t = prettyPrintOne(c);
           }
           catch (err) {
            $('#report').html(err + c);
           }
           // undisguise
           for (var i = 0 ; i < thingsThatScrewUp.length ; i++ ) {
             t = t.replace(new RegExp("sandw_" + i + "_ch", 'g'),thingsThatScrewUp[i]);
           }
           $(elem).html("<pre class='code pretty prettyprint'>" + t + "</pre>");
          });
          $('#working').html('Module:');
      });
    

    Here’s a Working version

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to prepare my activity's how to use windows but I am
I'm trying to delete with qt with this code: int jobId = 655; query.prepare(DELETE
I am trying to prepare a string for use as a directory listing. I
I'm trying to use Command.Prepare with a CommandType.Text query that has a single input
I'm trying to use matplotlib to prepare some figures for publication. In order to
I have problem with declaration of variable. iam trying to prepare code using Multi
I'm trying to improve some existing code which originally took 3 minutes to prepare
I am trying to use the TexTMessage interface to prepare a SMS before invoking
i am trying to use mysql function FROM_UNIXTIME together with PDO: $sth = $dbh->prepare(UPDATE
I'm trying to use SQLBindParameter to prepare my driver for input via SQLPutData .

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.