chensenlai 10988628a0 语音房项目初始化 пре 5 година
..
lib 10988628a0 语音房项目初始化 пре 5 година
node_modules 10988628a0 语音房项目初始化 пре 5 година
.npmignore 10988628a0 语音房项目初始化 пре 5 година
README.md 10988628a0 语音房项目初始化 пре 5 година
package.json 10988628a0 语音房项目初始化 пре 5 година

README.md

babel-template

Generate an AST from a string template.

In computer science, this is known as an implementation of quasiquotes.

Install

$ npm install babel-template

Usage

import template from 'babel-template';
import generate from 'babel-generator';
import * as t from 'babel-types';

const buildRequire = template(`
  var IMPORT_NAME = require(SOURCE);
`);

const ast = buildRequire({
  IMPORT_NAME: t.identifier('myModule'),
  SOURCE: t.stringLiteral('my-module')
});

console.log(generate(ast).code);
var myModule = require('my-module');