diff --git a/vlib/vweb/tmpl/tmpl.v b/vlib/vweb/tmpl/tmpl.v index f65749d6cb..17db759026 100644 --- a/vlib/vweb/tmpl/tmpl.v +++ b/vlib/vweb/tmpl/tmpl.v @@ -19,6 +19,13 @@ pub fn compile_file(path, fn_name string) string { return compile_template(html, fn_name) } +enum State { + html + css // ' { - // in_css = false + state = .html + } + else if line == '' { + state = .html } if line.contains('@if ') { s.writeln(str_end) @@ -74,23 +86,23 @@ pub fn compile_template(content, fn_name string) string { } s.writeln('for ' + line[pos + 4..] + '{') s.writeln(str_start) - } else if !in_css && line.contains('span.') && line.ends_with('{') { + } else if state == .html && line.contains('span.') && line.ends_with('{') { // `span.header {` => `` class := line.find_between('span.', '{').trim_space() s.writeln('') - in_span = true - } else if !in_css && line.contains('.') && line.ends_with('{') { + state = .span + } else if state == .html && line.contains('.') && line.ends_with('{') { // `.header {` => `
` class := line.find_between('.', '{').trim_space() s.writeln('
') - } else if !in_css && line.contains('#') && line.ends_with('{') { + } else if state == .html && line.contains('#') && line.ends_with('{') { // `#header {` => `