mirror of
https://github.com/vlang/v.git
synced 2025-09-14 15:02:33 +03:00
This commit is contained in:
parent
59d5115483
commit
3115796756
3 changed files with 15 additions and 3 deletions
|
@ -77,9 +77,8 @@ fn insert_template_code(fn_name string, tmpl_str_start string, line string) stri
|
|||
// HTML, may include `@var`
|
||||
// escaped by cgen, unless it's a `vweb.RawHtml` string
|
||||
trailing_bs := tmpl_str_end + 'sb_${fn_name}.write_u8(92)\n' + tmpl_str_start
|
||||
round1 := ['\\', '\\\\', r"'", "\\'", r'@', r'$']
|
||||
round2 := [r'$$', r'\@', r'.$', r'.@']
|
||||
mut rline := line.replace_each(round1).replace_each(round2)
|
||||
replace_pairs := ['\\', '\\\\', r"'", "\\'", r'@', r'$', r'$$', r'\@']
|
||||
mut rline := line.replace_each(replace_pairs)
|
||||
comptime_call_str := rline.find_between('\${', '}')
|
||||
if comptime_call_str.contains("\\'") {
|
||||
rline = rline.replace(comptime_call_str, comptime_call_str.replace("\\'", r"'"))
|
||||
|
|
2
vlib/v/tests/tmpl/dot_var.txt
Normal file
2
vlib/v/tests/tmpl/dot_var.txt
Normal file
|
@ -0,0 +1,2 @@
|
|||
.@one
|
||||
.${two}
|
11
vlib/v/tests/tmpl_dot_var_test.v
Normal file
11
vlib/v/tests/tmpl_dot_var_test.v
Normal file
|
@ -0,0 +1,11 @@
|
|||
fn template() string {
|
||||
one := 1
|
||||
two := 2
|
||||
return $tmpl('tmpl/dot_var.txt')
|
||||
}
|
||||
|
||||
fn test_tmpl_with_dot_var() {
|
||||
assert template() == '.1
|
||||
.2
|
||||
'
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue