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

Coffee/PHP/SHELL: alternative @echo usage with end delimiter #105

Closed
kirly-af opened this issue Apr 12, 2016 · 0 comments
Closed

Coffee/PHP/SHELL: alternative @echo usage with end delimiter #105

kirly-af opened this issue Apr 12, 2016 · 0 comments

Comments

@kirly-af
Copy link
Contributor

Let's consider the following use case:

'use strict';

const pp = require('preprocess');
require('shelljs/global');
const context = {BAR: 'foobar'};

pp.preprocessFile('./in.js', './out.js', context, () => {
    echo('js:');
    console.log(cat('out.js'));
});

pp.preprocessFile('./in.coffee', './out.coffee', context, () => {
    echo('coffee:');
    console.log(cat('out.coffee'));
});
// in.js
var foo = "/* @echo BAR */";
# in.coffee
foo_undef = '# @echo BAR '
foo = # @echo BAR
foo_workaround = """
# @echo BAR
"""

This will produce the following output:

js:                    
var foo = "foobar";    

coffee:                
foo_undef = 'undefined 
foo = foobar           
foo_workaround = """   
foobar                 
"""

As shown with the 1st coffee example (foo_undef), Coffeescript syntax currently does not allow to preprocess strings with @echo on a single line.

An alternative syntax for convenience could be:

foo = ' ### @echo BAR ###'    # output: foo = 'foobar'
@pioug pioug closed this as completed in aced572 Apr 14, 2020
straker added a commit to straker/preprocess that referenced this issue Jun 30, 2020
* 'master' of https://github.com/jsoverson/preprocess:
  Drop support of Node < 10
  Update npm dependencies
  3.2.0
  revert version, let np do the work
  Release v3.2.0
  Run CI with LTS and latest Node versions
  Do not use latest npm on Travis
  Support for if-else-endif. Regexps for HTML, JS and CoffeScript only. Shallow tests.
  Return a blank string if the env var is undefined
  added .json file extension as alias for .js
  add test for coffeescript echo directive
  fix jsoverson#105 : [coffee] add block comment syntax for echo directive
  Fix for parenthesis not being allowed in @exec string parameters
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

1 participant