Skip to content

Commit

Permalink
Make mustache.mjs work with Deno
Browse files Browse the repository at this point in the history
Minor adjustments needed to make the TypeScript compiler
that is built into Deno, be happy with how mustache.js'
ES module source looks in terms of function parameters
passed and object mutability.

Refs #1
  • Loading branch information
zekth authored and phillipj committed Oct 17, 2019
1 parent 01d2cc8 commit 0647792
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions mustache.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@
* http://github.com/janl/mustache.js
*/

import { version } from './package.json';
import _package from './package.json';

var version = _package.version;
var objectToString = Object.prototype.toString;
var isArray = Array.isArray || function isArrayPolyfill (object) {
return objectToString.call(object) === '[object Array]';
Expand Down Expand Up @@ -522,7 +523,7 @@ Writer.prototype.parse = function parse (template, tags) {
*/
Writer.prototype.render = function render (template, view, partials, tags) {
var tokens = this.parse(template, tags);
var context = (view instanceof Context) ? view : new Context(view);
var context = (view instanceof Context) ? view : new Context(view, undefined);
return this.renderTokens(tokens, context, partials, template, tags);
};

Expand Down Expand Up @@ -647,7 +648,15 @@ Writer.prototype.rawValue = function rawValue (token) {
var mustache = {
name: 'mustache.js',
version: version,
tags: [ '{{', '}}' ]
tags: [ '{{', '}}' ],
clearCache: undefined,
escape: undefined,
parse: undefined,
render: undefined,
to_html: undefined,
Scanner: undefined,
Context: undefined,
Writer: undefined
};

// All high-level mustache.* functions use this writer.
Expand Down Expand Up @@ -708,4 +717,4 @@ mustache.Scanner = Scanner;
mustache.Context = Context;
mustache.Writer = Writer;

export default mustache;
export default mustache;

0 comments on commit 0647792

Please sign in to comment.