1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

.div hack

This commit is contained in:
Alexander Medvednikov 2019-07-30 22:33:20 +02:00
parent 8bb41d2de5
commit 95d76993c9
2 changed files with 25 additions and 2 deletions

View File

@ -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 == '<style>' {
in_css = true
}
else if line == '</style>' {
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('<div class="$class">')
}
else if !in_css && line == '}' {
s.writeln('</div>')
}
// HTML, may include `@var`
else {
s.writeln(line.replace('@', '\x24').replace('\'', '"') )
}

View File

@ -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 (