v icon indicating copy to clipboard operation
v copied to clipboard

template allows $ instead of @

Open ghost opened this issue 3 years ago • 4 comments

V version: ArchLinux OS: 0.2.4 e031096

What did you do?

https://github.com/vlang/v/blob/master/doc/docs.md#tmpl-for-embedding-and-parsing-v-template-files

I get the same result when I change 1.txt as follows although this is intentional or a bug.

name: $name

age: $age

numbers: $numbers

@for number in numbers
  $number
@end

What did you expect to see? The part where @ is changed to $ is ignored.

What did you see instead? No error.

ghost avatar Jun 19 '22 10:06 ghost

I'm not familiar with this part of v, but I'm assuming in here is why the bug occurs; it uses '$' as a special keyword, as it turns '@' into '$', but if you already have $ initially, it'll just go straight to being processed. The simplest solution would be to perhaps disallow the '$' character in the template code? I wouldn't mind attempting it.

mjh316 avatar Jun 22 '22 04:06 mjh316

Hmm.. If V tries to parse $, there will be a conflict with the javascript template and will not compile.

ghost avatar Jun 24 '22 16:06 ghost

I see it works just like is expected to work. Confirm @medvednikov ?

felipensp avatar Sep 27 '24 22:09 felipensp

No, I think it should only allow @. One way and everything. I didn't intend for $ to work, it's an unintended bug, since templates are compiled into V code, and $ is used for string interpolation.

medvednikov avatar Sep 27 '24 23:09 medvednikov