mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
tests: test more vweb template features
This commit is contained in:
parent
d7c63922d5
commit
30ade1d6ea
@ -2,3 +2,14 @@ Test <b>app</b>
|
|||||||
<br>
|
<br>
|
||||||
<h1>@hello</h1>
|
<h1>@hello</h1>
|
||||||
<hr>
|
<hr>
|
||||||
|
@if show
|
||||||
|
show = true
|
||||||
|
@end
|
||||||
|
|
||||||
|
@for number in numbers
|
||||||
|
@number <br>
|
||||||
|
@end
|
||||||
|
|
||||||
|
|
||||||
|
<hr>
|
||||||
|
End.
|
||||||
|
@ -27,8 +27,10 @@ pub fn (mut app App) json_endpoint() {
|
|||||||
|
|
||||||
pub fn (mut app App) index() {
|
pub fn (mut app App) index() {
|
||||||
app.cnt++
|
app.cnt++
|
||||||
|
show:= true
|
||||||
//app.vweb.text('Hello world from vweb')
|
//app.vweb.text('Hello world from vweb')
|
||||||
hello := 'Hello world from vweb'
|
hello := 'Hello world from vweb'
|
||||||
|
numbers := [1,2,3]
|
||||||
$vweb.html()
|
$vweb.html()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -43,7 +43,7 @@ pub fn compile_template(content string) string {
|
|||||||
//footer := \'footer\'
|
//footer := \'footer\'
|
||||||
")
|
")
|
||||||
s.writeln(str_start)
|
s.writeln(str_start)
|
||||||
mut in_css := true // false
|
mut in_css := false// false
|
||||||
for _line in lines {
|
for _line in lines {
|
||||||
line := _line.trim_space()
|
line := _line.trim_space()
|
||||||
if line == '<style>' {
|
if line == '<style>' {
|
||||||
@ -79,6 +79,7 @@ pub fn compile_template(content string) string {
|
|||||||
s.writeln(str_start)
|
s.writeln(str_start)
|
||||||
}
|
}
|
||||||
else if !in_css && line.contains('.') && line.ends_with('{') {
|
else if !in_css && line.contains('.') && line.ends_with('{') {
|
||||||
|
// `.header {` => `<div class='header'>`
|
||||||
class := line.find_between('.', '{')
|
class := line.find_between('.', '{')
|
||||||
s.writeln('<div class="$class">')
|
s.writeln('<div class="$class">')
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user