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

can't remove #31

Closed
atian25 opened this issue Jan 10, 2014 · 8 comments
Closed

can't remove #31

atian25 opened this issue Jan 10, 2014 · 8 comments

Comments

@atian25
Copy link

atian25 commented Jan 10, 2014

cfg:

preprocess : {
      options: {
        inline: true,
        context : {
        }
      },
      prod: {
        src: 'index.html',
        dest: 'index2.html'
      }
    }

input:

<!doctype html>
<html>
<body>
<!-- @ifndef DEBUG --> 
<script>
  console.group('init');
  console.time('load script');
</script>
<!-- @endif -->
<script>
  // @ifndef DEBUG
  console.timeEnd('load script');
  console.time('load sea script');
  // @endif
</script>
</body>
</html>

output:

<!doctype html>
<html>
<body>

<script>
  console.group('init');
  console.time('load script');
</script>
<script>
  // @ifndef DEBUG
  console.timeEnd('load script');
  console.time('load sea script');
  // @endif
</script>
</body>
</html>
@drkibitz
Copy link

ifndef -> ifdef

@atian25
Copy link
Author

atian25 commented Jan 10, 2014

but as doc here, https://github.com/jsoverson/preprocess
support @ifndef VAR

only use this task at build:prod, so need @ifndef DEBUG

@drkibitz
Copy link

Sorry didn't even know that existed, and obviously never used it ;)

@drkibitz
Copy link

Ah wait, this is html no?

@drkibitz
Copy link

You must use html style comments for both blocks, see #20

@atian25
Copy link
Author

atian25 commented Jan 10, 2014

it don't work for me.

when use 2 @ifndef then neither is remove

<!doctype html>
<html>
<body>
<!-- @ifndef DEBUG --> 
<script>
  console.group('init');
  console.time('load script');
</script>
<!-- @endif -->
<script>
  <!-- @ifndef DEBUG --> 
  // console.timeEnd('load script');
  var a = 'b'
  console.time('load sea script');
  <!-- @endif -->
</script>
</body>
</html>

will result:

<!doctype html>
<html>
<body>

<script>
  console.group('init');
  console.time('load script');
</script>
<script>

  // console.timeEnd('load script');
  var a = 'b'
  console.time('load sea script');
</script>
</body>
</html>

@pauldijou
Copy link

I don't really understand the problem here. @ifndef blocks will be included if the variable is not defined. Since you have an empty context, DEBUG isn't defined and then both blocks are rendered.

@jsoverson
Copy link
Owner

Agreed, this doesn't seem like an issue with the logic.

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

4 participants