Referencing mustache.js in quickbase pages

  • 0
  • 1
  • Question
  • Updated 10 months ago
  • In Progress
I'm looking to reference the mustache.js source from within a quickbase html page - how do I do this.

(I looked at the example at haversine consulting - but it doesn't work anymore :( )
Photo of Ian` Turner

Ian` Turner

  • 366 Points 250 badge 2x thumb

Posted 1 year ago

  • 0
  • 1
Photo of Ian` Turner

Ian` Turner

  • 366 Points 250 badge 2x thumb
I am getting an error
GET https://login.quickbase.com/js/mustache-0.5.0 404 (Not Found)

when the script that is trying to be loaded is referenced at www.quickbase.com in the code.
Photo of Ian` Turner

Ian` Turner

  • 366 Points 250 badge 2x thumb
Fixed - Typo in script reference.
Photo of Ⲇanom the ultimate (Dan Diebolt)

Ⲇanom the ultimate (Dan Diebolt), Champion

  • 26,572 Points 20k badge 2x thumb
Maybe one of these URLs is what you want:

https://login.quickbase.com/js/mustache-0.5.0.js

https://assets.quickbasecdn.net/res/75807-10/js/mustache-0.5.0.js

Note the CDN URL has a release number in it (75807-10) and will eventually go stale as QuickBase pushes out new releases. This is why some of my demos break over time. It might be better to pull the library (1) from a code page where you can completely control the library version or (2) from a public CDN whose URL does not change.
Photo of Ian` Turner

Ian` Turner

  • 366 Points 250 badge 2x thumb
Despite referencing https://www.quickbase.com/js/mustache-0.5.0.js in the page code

I still get unsafe script warnings for http://www.quickbase.com/js/mustache-0.5.0.js 

so I assume that the server that stores this is not running a current SSL cert
Photo of Ian` Turner

Ian` Turner

  • 366 Points 250 badge 2x thumb
Photo of Ⲇanom the ultimate (Dan Diebolt)

Ⲇanom the ultimate (Dan Diebolt), Champion

  • 26,572 Points 20k badge 2x thumb
>I still get unsafe script warnings for http://www.quickbase.com/js/mustache-0.5.0.js 

You are using mixed content here - the error should go away if you use https instead of http.

Also if you are using Mustache on a QuickBase page Mustache is already loaded! To prove this just paste code into the console:

var person = {
    firstName: "Christophe",
    lastName: "Coenraets",
    blogURL: "http://coenraets.org";
};
var template = "<h1>{{firstName}} {{lastName}}</h1>Blog: {{blogURL}}";
var html = Mustache.to_html(template, person);
console.log(html);
// output: <h1>Christophe Coenraets</h1>Blog: http://coenraets.org
Photo of Ian` Turner

Ian` Turner

  • 366 Points 250 badge 2x thumb
The interesting thing was that I had the https in the script reference on the page and was getting the mixed content warning.

I am using the Pages section of the App to create HTML pages - if I omit the script reference it just tells me Mustache is not defined.
Photo of Robert

Robert

  • 214 Points 100 badge 2x thumb
I just started working with Mustache and I also get a Mustache not defined message if I do not include it. This works when referencing https://cdnjs.cloudflare.com/ajax/libs/mustache.js/2.3.0/mustache.js

 <script>
      var view = {
        name : "Joe",
        occupation : "Web Developer"
      };

      function loadtemp(){
        var output = Mustache.render("{{name}} is a  {{occupation}}", view);
        document.getElementById('person').innerHTML = output;
      }
    </script>

  <body onload="loadtemp()" >
    <p id="person"></p>
  </body>