diff --git a/vlib/vweb/tmpl/tmpl.v b/vlib/vweb/tmpl/tmpl.v index 9ae2f49ced..4a108e60ce 100644 --- a/vlib/vweb/tmpl/tmpl.v +++ b/vlib/vweb/tmpl/tmpl.v @@ -1,3 +1,7 @@ +// Copyright (c) 2019 Alexander Medvednikov. All rights reserved. +// Use of this source code is governed by an MIT license +// that can be found in the LICENSE file. + module tmpl import os @@ -33,7 +37,15 @@ _ := header //footer := \'footer\' ') s.writeln(STR_START) - for line in lines { + mut in_css := false + for _line in lines { + line := _line.trim_space() + if line == '' { + in_css = false + } if line.contains('@if ') { s.writeln(STR_END) pos := line.index('@if') @@ -56,7 +68,14 @@ _ := header s.writeln('for ' + line.right(pos + 4) + '{') s.writeln(STR_START) } - // @name + else if !in_css && line.contains('.') && line.ends_with('{') { + class := line.find_between('.', '{') + s.writeln('
') + } + else if !in_css && line == '}' { + s.writeln('
') + } + // HTML, may include `@var` else { s.writeln(line.replace('@', '\x24').replace('\'', '"') ) } diff --git a/vlib/vweb/vweb.v b/vlib/vweb/vweb.v index aa4c89ba1c..7c95c10521 100644 --- a/vlib/vweb/vweb.v +++ b/vlib/vweb/vweb.v @@ -1,3 +1,7 @@ +// Copyright (c) 2019 Alexander Medvednikov. All rights reserved. +// Use of this source code is governed by an MIT license +// that can be found in the LICENSE file. + module vweb import (