vweb: enable @ logic in the header + fix the example

pull/3029/head
Alexander Medvednikov 2019-12-09 23:32:21 +03:00
parent 6f49d4c1d2
commit 51051cdf92
2 changed files with 4 additions and 3 deletions

View File

@ -31,7 +31,7 @@ pub fn (app mut App) index() {
$vweb.html() $vweb.html()
} }
pub fn (app & App) text() { pub fn (app mut App) text() {
app.vweb.text('Hello world') app.vweb.text('Hello world')
} }

View File

@ -15,7 +15,7 @@ const (
pub fn compile_template(path string) string { pub fn compile_template(path string) string {
//lines := os.read_lines(path) //lines := os.read_lines(path)
html := os.read_file(path) or { mut html := os.read_file(path) or {
panic('html failed') panic('html failed')
} }
mut header := '' mut header := ''
@ -24,13 +24,14 @@ pub fn compile_template(path string) string {
panic('html failed') panic('html failed')
} }
header = h.replace('\'', '"') header = h.replace('\'', '"')
html = header + html
} }
lines := html.split_into_lines() lines := html.split_into_lines()
mut s := strings.new_builder(1000) mut s := strings.new_builder(1000)
//base := path.all_after('/').replace('.html', '') //base := path.all_after('/').replace('.html', '')
s.writeln(' s.writeln('
mut sb := strings.new_builder(${lines.len * 30}) mut sb := strings.new_builder(${lines.len * 30})
header := \'$header\' header := \' \' // TODO remove
_ = header _ = header
//footer := \'footer\' //footer := \'footer\'
') ')