From 9355048b6c37d04b961bcc06b32746b37f873e4c Mon Sep 17 00:00:00 2001 From: Alexander Medvednikov Date: Sat, 23 Apr 2022 16:01:39 +0300 Subject: [PATCH] tmpl: minor fixes and optimizations --- vlib/v/parser/tmpl.v | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/vlib/v/parser/tmpl.v b/vlib/v/parser/tmpl.v index fe70bef9af..910fcb8748 100644 --- a/vlib/v/parser/tmpl.v +++ b/vlib/v/parser/tmpl.v @@ -256,30 +256,27 @@ fn vweb_tmpl_${fn_name}() string { match state { .html { - if line.starts_with('span.') && line.ends_with('{') { + line_t := line.trim_space() + if line_t.starts_with('span.') && line.ends_with('{') { // `span.header {` => `` class := line.find_between('span.', '{').trim_space() source.writeln('') in_span = true continue - } - if line.trim_space().starts_with('.') && line.ends_with('{') { + } else if line_t.starts_with('.') && line.ends_with('{') { // `.header {` => `
` class := line.find_between('.', '{').trim_space() trimmed := line.trim_space() source.write_string(strings.repeat(`\t`, line.len - trimmed.len)) // add the necessary indent to keep
code clean source.writeln('
') continue - } - if line.starts_with('#') && line.ends_with('{') { + } else if line_t.starts_with('#') && line.ends_with('{') { // `#header {` => `