From 95d76993c9ca563ab10a25078864c2d719f2b39b Mon Sep 17 00:00:00 2001 From: Alexander Medvednikov Date: Tue, 30 Jul 2019 22:33:20 +0200 Subject: [PATCH] .div hack --- vlib/vweb/tmpl/tmpl.v | 23 +++++++++++++++++++++-- vlib/vweb/vweb.v | 4 ++++ 2 files changed, 25 insertions(+), 2 deletions(-) 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 (