Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Make mustache.mjs work with Deno #1

Merged
merged 1 commit into from
Oct 17, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;