Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
felipensp committed Sep 24, 2024
1 parent 41e045c commit 6071e06
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion vlib/v/parser/tmpl.v
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ 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
replace_pairs := ['\\', '\\\\', r"'", "\\'", r'@', r'$', r'$$', r'\@']
replace_pairs := ['\\', '\\\\', r"'", "\\'", r'@@', r'@', r'@', r'$', r'$$', r'\@']
mut rline := line.replace_each(replace_pairs)
comptime_call_str := rline.find_between('\${', '}')
if comptime_call_str.contains("\\'") {
Expand Down
9 changes: 9 additions & 0 deletions vlib/v/tests/tmpl_escape_test.v
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
fn test_escape() {
world := 'world!'
res := $tmpl('tmpl/escape.txt')

assert res == 'Hello @world
Hello world!
Hello $ world! $
'
}

0 comments on commit 6071e06

Please sign in to comment.