diff --git a/vlib/v/parser/tmpl.v b/vlib/v/parser/tmpl.v index b3fe8682f2405e..f6ab95a0805ba0 100644 --- a/vlib/v/parser/tmpl.v +++ b/vlib/v/parser/tmpl.v @@ -242,7 +242,6 @@ fn vweb_tmpl_${fn_name}() string { mut end_of_line_pos := 0 mut start_of_line_pos := 0 mut tline_number := -1 // keep the original line numbers, even after insert/delete ops on lines; `i` changes - mut in_write := false // continuing string write code for i := 0; i < lines.len; i++ { line := lines[i] tline_number++ @@ -329,13 +328,12 @@ fn vweb_tmpl_${fn_name}() string { pos := line.index('@if') or { continue } source.writeln('if ' + line[pos + 4..] + '{') source.write_string(tmpl_str_start) - in_write = true continue } if line.contains('@end') { source.writeln(tmpl_str_end) source.writeln('}') - source.writeln(tmpl_str_start) + source.write_string(tmpl_str_start) continue } if line.contains('@else') { @@ -344,7 +342,6 @@ fn vweb_tmpl_${fn_name}() string { source.writeln('}' + line[pos + 1..] + '{') // source.writeln(' } else { ') source.write_string(tmpl_str_start) - in_write = true continue } if line.contains('@for') { @@ -356,15 +353,10 @@ fn vweb_tmpl_${fn_name}() string { } if state == .simple { // by default, just copy 1:1 - if in_write { - source.write_string(insert_template_code(fn_name, tmpl_str_start, line)) - } else { - source.writeln(insert_template_code(fn_name, tmpl_str_start, line)) - } - in_write = false + source.writeln(insert_template_code(fn_name, tmpl_str_start, line)) continue } - in_write = false + //in_write = false // The .simple mode ends here. The rest handles .html/.css/.js state transitions. if state != .simple { diff --git a/vlib/v/tests/tmpl_test.v b/vlib/v/tests/tmpl_test.v index aeecaa309c0e13..09c6f204abb64b 100644 --- a/vlib/v/tests/tmpl_test.v +++ b/vlib/v/tests/tmpl_test.v @@ -32,7 +32,6 @@ numbers: [1, 2, 3] 2 3 - 0 - 0 2 - 1 4 - 2 @@ -44,11 +43,9 @@ numbers: [1, 2, 3] 16 - 8 18 - 9 - vlang/ui, downloaded 3201 times. vlang/vtl, downloaded 123 times. - this is not ignored so, it's basically true" @@ -73,7 +70,6 @@ numbers: [1, 2, 3] 2 3 - 0 - 0 2 - 1 4 - 2 @@ -85,11 +81,9 @@ numbers: [1, 2, 3] 16 - 8 18 - 9 - vlang/ui, downloaded 3201 times. vlang/vtl, downloaded 123 times. - this is not ignored so, it's basically true" @@ -146,16 +140,3 @@ fn test_tmpl_include_grandchild() { child_tmpl := $tmpl('tmpl/nested/nested_deeper/grandchild.html') assert child_tmpl.contains(expected) } - -fn test_tmpl_if_cond() { - cond := true - processed := $tmpl('tmpl/if_cond.txt') - assert processed == 'aaa -bbb -ccc - -aaa -bbb -ccc -' -}