Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

On custom template, Handlebars regex causes Metalsmith to erroneously target non-handlebars files #167

Closed
enlore opened this issue Sep 11, 2016 · 1 comment

Comments

@enlore
Copy link

enlore commented Sep 11, 2016

Hey all. I'm on my way to a hackathon so I forked the vuejs/browserify template and threw some css and js files in there to make a simple Vue/Material Design Lite project template. The template generation process barfs, as follows:

mqi7918 at CORPMQI7918MB.local in [~/projects/code/access-to-law]   
14:48:18 › vue --version
2.3.1

mqi7918 at CORPMQI7918MB.local in [~/projects/code/access-to-law]   
14:46:10 › vue init enlore/browserify-mdl my-project

# a bunch of crap cut for brevity

/usr/local/lib/node_modules/vue-cli/bin/vue-init:165
          throw err
          ^

Error: Parse error on line 420:
... * * @typedef {{ *   constructor: Fun
--------------------^
Expecting 'ID', 'STRING', 'NUMBER', 'BOOLEAN', 'UNDEFINED', 'NULL', 'DATA', got 'INVALID'
    at Object.parseError (/usr/local/lib/node_modules/vue-cli/node_modules/handlebars/dist/cjs/handlebars/compiler/parser.js:267:19)
    at Object.parse (/usr/local/lib/node_modules/vue-cli/node_modules/handlebars/dist/cjs/handlebars/compiler/parser.js:336:30)
    at HandlebarsEnvironment.parse (/usr/local/lib/node_modules/vue-cli/node_modules/handlebars/dist/cjs/handlebars/compiler/base.js:46:43)
    at compileInput (/usr/local/lib/node_modules/vue-cli/node_modules/handlebars/dist/cjs/handlebars/compiler/compiler.js:514:19)
    at ret (/usr/local/lib/node_modules/vue-cli/node_modules/handlebars/dist/cjs/handlebars/compiler/compiler.js:523:18)
    at /usr/local/lib/node_modules/vue-cli/node_modules/consolidate/lib/consolidate.js:734:16
    at /usr/local/lib/node_modules/vue-cli/node_modules/consolidate/lib/consolidate.js:143:5
    at Promise._execute (/usr/local/lib/node_modules/vue-cli/node_modules/consolidate/node_modules/bluebird/js/release/debuggability.js:299:9)
    at Promise._resolveFromExecutor (/usr/local/lib/node_modules/vue-cli/node_modules/consolidate/node_modules/bluebird/js/release/promise.js:481:18)
    at new Promise (/usr/local/lib/node_modules/vue-cli/node_modules/consolidate/node_modules/bluebird/js/release/promise.js:77:14)
    at promisify (/usr/local/lib/node_modules/vue-cli/node_modules/consolidate/lib/consolidate.js:136:10)
    at exports.handlebars.render (/usr/local/lib/node_modules/vue-cli/node_modules/consolidate/lib/consolidate.js:724:10)
    at /usr/local/lib/node_modules/vue-cli/lib/generate.js:102:5
    at /usr/local/lib/node_modules/vue-cli/node_modules/async/dist/async.js:3047:20
    at eachOfArrayLike (/usr/local/lib/node_modules/vue-cli/node_modules/async/dist/async.js:1002:13)
    at eachOf (/usr/local/lib/node_modules/vue-cli/node_modules/async/dist/async.js:1052:9)

(I hacked a throw statement in there so I could generate a more informative error message, which itself suggests a different issue about the informative quality of the errors thrown.)

material.js, the JS file packaged with MDL, has lines like this:

 * @typedef {{ 

This causes a false positive insofar as vue-cli's efforts to sniff out files that contain Handlebars tags.

I'll be happy to put a PR together to ameliorate this issue in a few days. I'd like some feedback about how to handle this.

  • Add a property to the meta file to exclude things? "exclude": ["dist/**/*.css", "dist/**/*.js", "custom-dir/**/*", "src/my-project-meta.json"], that sort of thing
  • Be more explicit about files to process w/Handlebars, since (at least in the browserify template) there's only the one file that has Handlebars tags? Same technique, adding a property to meta: "include": ["package.json"/*, etc */]
@posva
Copy link
Member

posva commented Sep 11, 2016

Including libs directly into vue-cli templates doesn't look like a good idea. They should be installed through a package manager.
As for your hackathon I recommend you starting from a working project generated with vue and then adding the libs to that. That's way less riskier.
As for {{}} in handelbars, you can escape them with \{{ hello }}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants