Skip to content

Commit

Permalink
amp-mustache: emit a developer error for faulty mustache templates (#…
Browse files Browse the repository at this point in the history
…27434)

* amp-mustache: emit a developer error for faulty mustache templates

* dev-->user
  • Loading branch information
samouri committed Mar 27, 2020
1 parent 025a0f4 commit adae783
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion extensions/amp-mustache/0.2/amp-mustache.js
Expand Up @@ -19,6 +19,7 @@ import {dict} from '../../../src/utils/object';
import {getService, registerServiceBuilder} from '../../../src/service';
import {iterateCursor, templateContentClone} from '../../../src/dom';
import {rewriteAttributeValue} from '../../../src/url-rewrite';
import {user} from '../../../src/log';
import mustache from '../../../third_party/mustache/mustache';

const TAG = 'amp-mustache';
Expand Down Expand Up @@ -66,7 +67,11 @@ export class AmpMustache extends BaseTemplate {
/** @private @const {string} */
this.template_ = this.initTemplateString_();

mustache.parse(this.template_, /* tags */ undefined);
try {
mustache.parse(this.template_, /* tags */ undefined);
} catch (err) {
user().error(TAG, err.message, this.element);
}
}

/**
Expand Down

0 comments on commit adae783

Please sign in to comment.