v icon indicating copy to clipboard operation
v copied to clipboard

V doesn't ignore variables in HTML comment template

Open aviadb opened this issue 4 years ago • 5 comments

V version: V 0.2.4 d373eba, timestamp: 2021-10-13 09:40:14 +0300 **OS: linux, Linux version 5.14.10-200.fc34.x86_64 **

What did you do? Create a template file with an HTML comment <!-- @numbers -->

Do not declare or init any variable

What did you expect to see? Nothing, V should not parse comments

What did you see instead? error: undefined ident: numbers

aviadb avatar Oct 13 '21 15:10 aviadb

Example?

JalonSolov avatar Oct 13 '21 15:10 JalonSolov

Simple vweb setup that loads a template file with an HTML comment. Do you prefer a full working example?

aviadb avatar Oct 13 '21 15:10 aviadb

Something that will show the error message.

Question: Is numbers in your template as @numbers? If so, that's an easy "fix" - to escape the @ so it isn't seen as a template variable, double it, as in @@number.

JalonSolov avatar Oct 13 '21 16:10 JalonSolov

Yes, escaping the variable, i.e. @@numbers solves the problem. However, it would be great to have the flexibility of commenting inside a template file.

aviadb avatar Oct 13 '21 16:10 aviadb

Using @@ should work whether it's in a comment or not.

It works everywhere now, in case you actually do want to use it to replace something, even in comments.

JalonSolov avatar Oct 13 '21 16:10 JalonSolov