GithubHelp home page GithubHelp logo

estools / estemplate Goto Github PK

View Code? Open in Web Editor NEW
105.0 105.0 10.0 21 KB

Proper (AST-based) JavaScript code templating with source maps support.

JavaScript 100.00%
ast ecmascript estree javascript

estemplate's People

Contributors

c-vetter avatar rreverser avatar trysound avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

estemplate's Issues

Associative arrays

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?

Error "Unknown substitution in Program"

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?

Just a curious question

Do you think this could lead to work to generate AST trees for language code blocks other than Javascript?

Suggest to update simple usage

console.log(escodegen.generate(ast));

When I copy paste your simple usage, this line through me error. could add that reference

Sample code does not work with gulp-wrap-js

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.