From 8a7ddd102e604db5da10dbf5a34a9c7e8323dea8 Mon Sep 17 00:00:00 2001 From: Alexander Medvednikov Date: Wed, 31 Jul 2019 03:41:39 +0200 Subject: [PATCH] vweb: tmpl fixes --- compiler/comptime.v | 10 +++++++++- vlib/vweb/tmpl/tmpl.v | 2 +- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/compiler/comptime.v b/compiler/comptime.v index 26244bb6d7..001c785ec1 100644 --- a/compiler/comptime.v +++ b/compiler/comptime.v @@ -77,6 +77,9 @@ fn (p mut Parser) comp_time() { // that returns an html string else if p.tok == .name && p.lit == 'vweb' { path := p.cur_fn.name + '.html' + if p.pref.is_debug { + println('compiling tmpl $path') + } if !os.file_exists(path) { p.error('vweb HTML template "$path" not found') } @@ -86,13 +89,18 @@ fn (p mut Parser) comp_time() { p.check(.lpar) p.check(.rpar) v_code := tmpl.compile_template(path) + if os.file_exists('.vwebtmpl.v') { + os.rm('.vwebtmpl.v') + } os.write_file('.vwebtmpl.v', v_code.clone()) // TODO don't need clone, compiler bug p.genln('') // Parse the function and embed resulting C code in current function so that // all variables are available. pos := p.cgen.lines.len - 1 mut pp := p.v.new_parser('.vwebtmpl.v', Pass.main) - os.rm('.vwebtmpl.v') + if !p.pref.is_debug { + os.rm('.vwebtmpl.v') + } pp.is_vweb = true pp.cur_fn = p.cur_fn // give access too all variables in current function pp.parse() diff --git a/vlib/vweb/tmpl/tmpl.v b/vlib/vweb/tmpl/tmpl.v index 4a108e60ce..159c4d8a46 100644 --- a/vlib/vweb/tmpl/tmpl.v +++ b/vlib/vweb/tmpl/tmpl.v @@ -25,7 +25,7 @@ pub fn compile_template(path string) string { panic('html failed') return '' } - header = h + header = h//.replace('\'', '"') } lines := html.split_into_lines() mut s := strings.new_builder(1000)