Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Yeoman generator.fs.copyTpl - How to output literal '<%'

I'm working on my first Yeoman generator and need to output some literal ejs tags for later processing. I'm able to achieve this by escaping the tag with an additional '%' per the ejs docs (http://ejs.co/). For example:

<%% myModule %>

I can process this without issue using the deprecated generator.template(), and the destination file contains the expected output:

<% myModule %>

However, when I attempt to use generator.fs.copyTpl() to process the same file, I get the following synthax error:

SyntaxError: Unexpected token %

Do I need to explicitly pass an escape character in the ejs options object? Is there something else I'm missing?

Any ideas? Thank you!

like image 538
idealboy Avatar asked Jun 05 '15 17:06

idealboy


1 Answers

Using <%% just works with ejs and yeoman-generator.

My guess is that you're not using the latest version of yeoman-generator.

Run this in your generator project:

npm install --save yeoman-generator@LATEST

Also, there's a useful tool called david to detect outdated dependencies.

npm -g install david
# Then in your project folder
david
like image 144
Simon Boudrias Avatar answered Oct 17 '22 21:10

Simon Boudrias