estools / estemplate Goto Github PK
View Code? Open in Web Editor NEWProper (AST-based) JavaScript code templating with source maps support.
Proper (AST-based) JavaScript code templating with source maps support.
Do you think this could lead to work to generate AST trees for language code blocks other than Javascript?
I'm using this through gulp-wrap-js and I have one step wrapping my files in IIFEs. Today, I added another one before that, adding some boilerplate code to a specific file, like so:
gulp.src('**/*.js')
.pipe(gulpIf(
'special.js',
wrapJs([
'var boilerplate = {};',
'%= body %'
].join('\n'))
))
.pipe(wrapJs([
'(function () {',
'"use strict";',
'%= body %',
'})();'
].join('\n')))
.pipe(gulp.dest('build/'))
That caused the error message "Unknown substitution in Program". I tracked that down and found that merely adding 'Program': 'body'
to spread
in estemplate.js
fixes that with no apparent downside. Is there a specific reason that this use-case hasn't been covered, am I missing something?
console.log(escodegen.generate(ast));
When I copy paste your simple usage, this line through me error. could add that reference
esprima 1.2.2 (large dep) -> 2.7.2
estraverse 1.7.1 -> 4.1.1
According to the docs, estemplate does support regular array templating. But what if I want to template an associative array? (object, or dictionary)
Does it support something like:
var a = {%= elements %};
If it doesn't, would it be too hard for someone (e.g.: me) to pick up a fork and implement it?
Hey!
Just wanted to leave a note, that the example:
define(function () { console.time('Module'); %= body %; console.timeEnd('Module'); });
does not work in conjunction with gulp-wrap-js. When I change the code to:
define(function () { console.time('Module'); {%= body %}; console.timeEnd('Module'); });
it works. Don't know if this is a bug in gulp-wrap-js or an error of the intro page.
Bye
Tschoartschi
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.