From 905c292a81b08a56acb464680ba6a2590297e525 Mon Sep 17 00:00:00 2001 From: Dialga Date: Tue, 7 Sep 2021 11:21:23 +1200 Subject: [PATCH] tmpl: enforce stricter line checking for html interpolation (#11413) --- vlib/v/parser/tmpl.v | 6 +++--- vlib/v/tests/inout/file.md | 1 + vlib/v/tests/inout/tmpl_all_in_one_folder.out | 1 + vlib/v/tests/inout/tmpl_all_in_one_folder.vv | 7 +++++++ 4 files changed, 12 insertions(+), 3 deletions(-) diff --git a/vlib/v/parser/tmpl.v b/vlib/v/parser/tmpl.v index 548e913f87..ed373fa9a9 100644 --- a/vlib/v/parser/tmpl.v +++ b/vlib/v/parser/tmpl.v @@ -193,16 +193,16 @@ mut sb := strings.new_builder($lstartlength)\n pos := line.index('@for') or { continue } source.writeln('for ' + line[pos + 4..] + '{') source.writeln(parser.tmpl_str_start) - } else if state == .html && line.contains('span.') && line.ends_with('{') { + } else if state == .html && line.starts_with('span.') && line.ends_with('{') { // `span.header {` => `` class := line.find_between('span.', '{').trim_space() source.writeln('') in_span = true - } else if state == .html && line.contains('.') && line.ends_with('{') { + } else if state == .html && line.starts_with('.') && line.ends_with('{') { // `.header {` => `
` class := line.find_between('.', '{').trim_space() source.writeln('
') - } else if state == .html && line.contains('#') && line.ends_with('{') { + } else if state == .html && line.starts_with('#') && line.ends_with('{') { // `#header {` => `