From 51051cdf9256335f628e0edc22ce932f12897981 Mon Sep 17 00:00:00 2001 From: Alexander Medvednikov Date: Mon, 9 Dec 2019 23:32:21 +0300 Subject: [PATCH] vweb: enable @ logic in the header + fix the example --- examples/vweb/vweb_example.v | 2 +- vlib/vweb/tmpl/tmpl.v | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/examples/vweb/vweb_example.v b/examples/vweb/vweb_example.v index 61e6328af6..c4197c3589 100644 --- a/examples/vweb/vweb_example.v +++ b/examples/vweb/vweb_example.v @@ -31,7 +31,7 @@ pub fn (app mut App) index() { $vweb.html() } -pub fn (app & App) text() { +pub fn (app mut App) text() { app.vweb.text('Hello world') } diff --git a/vlib/vweb/tmpl/tmpl.v b/vlib/vweb/tmpl/tmpl.v index 8dd95a25b6..e75784120d 100644 --- a/vlib/vweb/tmpl/tmpl.v +++ b/vlib/vweb/tmpl/tmpl.v @@ -15,7 +15,7 @@ const ( pub fn compile_template(path string) string { //lines := os.read_lines(path) - html := os.read_file(path) or { + mut html := os.read_file(path) or { panic('html failed') } mut header := '' @@ -24,13 +24,14 @@ pub fn compile_template(path string) string { panic('html failed') } header = h.replace('\'', '"') + html = header + html } lines := html.split_into_lines() mut s := strings.new_builder(1000) //base := path.all_after('/').replace('.html', '') s.writeln(' mut sb := strings.new_builder(${lines.len * 30}) -header := \'$header\' +header := \' \' // TODO remove _ = header //footer := \'footer\' ')