@jamestalmage/babel-template
Generate an AST from a string template.
Last updated 4 years ago by jamestalmage .
MIT · Repository · Original npm · Tarball · package.json
$ cnpm install @jamestalmage/babel-template 
SYNC missed versions from official npm registry.

babel-template

Generate an AST from a string template.

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');

Current Tags

  • 6.3.13                                ...           latest (4 years ago)

1 Versions

  • 6.3.13                                ...           4 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 1
Last Day 0
Last Week 1
Last Month 2
Dependencies (5)
Dev Dependencies (0)
None
Dependents (0)
None

Copyright 2014 - 2016 © taobao.org |