babel-template
Generate an AST from a string template.
In computer science, this is known as an implementation of quasiquotes.
Install
npm install --save-dev babel-template
Usage
;;; const buildRequire = ; const ast = ; console;
const myModule = ;
API
template(code, [opts])
code
Type: string
options
babel-template
accepts all of the options from babylon, and specifies
some defaults of its own:
allowReturnOutsideFunction
is set totrue
by default.allowSuperOutsideMethod
is set totrue
by default.
preserveComments
Type: boolean
Default: false
Set this to true
to preserve any comments from the code
parameter.
Return value
babel-template
returns a function
which is invoked with an optional object
of replacements. See the usage section for an example.