mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
tmpl: fix escaping @ (#11452)
This commit is contained in:
@@ -224,8 +224,15 @@ mut sb := strings.new_builder($lstartlength)\n
|
||||
} else {
|
||||
// HTML, may include `@var`
|
||||
// escaped by cgen, unless it's a `vweb.RawHtml` string
|
||||
source.writeln(line.replace_each([r'@', r'$', r'$$', r'@', r'.$', r'.@', r"'", r"\'",
|
||||
'\\', parser.tmpl_str_end + 'sb.write_b(92)\n' + parser.tmpl_str_start]))
|
||||
trailing_bs := parser.tmpl_str_end + 'sb.write_b(92)\n' + parser.tmpl_str_start
|
||||
round1 := ['\\', '\\\\', r"'", "\\'", r'@', r'$']
|
||||
round2 := [r'$$', r'\@', r'.$', r'.@']
|
||||
rline := line.replace_each(round1).replace_each(round2)
|
||||
if rline.ends_with('\\') {
|
||||
source.writeln(rline[0..rline.len - 2] + trailing_bs)
|
||||
} else {
|
||||
source.writeln(rline)
|
||||
}
|
||||
}
|
||||
}
|
||||
source.writeln(parser.tmpl_str_end)
|
||||
|
||||
Reference in New Issue
Block a user