Would you like to clone this notebook?

When you clone a notebook you are able to make changes without affecting the original notebook.

Cancel

Allow non-present substitutions

node v10.24.1
version: 2.0.0
endpointsharetweet
Currently, @babel/template will throw an error if you pass a substitution that isn't present in the template. While this is fine for static templates, it becomes very difficult to work with if you are creating a tool that allows the user to supply templated strings. In our case, we have something like "handlerbars", but for JavaScript. Here there may be many more possible substitutions than actually used by the user. A good compromise would be to make whether non-present subsistitutions throw be an option.
const template = require("@babel/template").default; const example = template("y = x"); example({ NOT_PRESENT: "hi" });
Loading…

no comments

    sign in to comment