From f6bdc6b87e49cfdf5f7fee10d5d5ee08e1485b66 Mon Sep 17 00:00:00 2001 From: Alexander Medvednikov Date: Tue, 21 Sep 2021 07:53:42 +0300 Subject: [PATCH] tmpl: fix
inside
--- examples/vweb/index.html | 8 ++++++++ vlib/v/parser/tmpl.v | 8 ++++++-- vlib/v/tests/inout/embedded.html | 5 +++++ vlib/v/tests/inout/file.html | 7 ++++++- vlib/v/tests/inout/tmpl_parse_html.out | 11 ++++++++++- 5 files changed, 35 insertions(+), 4 deletions(-) create mode 100644 vlib/v/tests/inout/embedded.html diff --git a/examples/vweb/index.html b/examples/vweb/index.html index d69ff7873..736f8d643 100644 --- a/examples/vweb/index.html +++ b/examples/vweb/index.html @@ -1,11 +1,19 @@ +@include 'header.html' + Test app

@hello


+ +If demo:
@if show show = true @end +

+ +For loop demo:
+ @for number in numbers @number
@end diff --git a/vlib/v/parser/tmpl.v b/vlib/v/parser/tmpl.v index 796da60e4..8bb8cda75 100644 --- a/vlib/v/parser/tmpl.v +++ b/vlib/v/parser/tmpl.v @@ -198,15 +198,19 @@ mut sb := strings.new_builder($lstartlength)\n class := line.find_between('span.', '{').trim_space() source.writeln('') in_span = true - } else if state == .html && line.starts_with('.') && line.ends_with('{') { + } else if state == .html && line.trim_space().starts_with('.') && line.ends_with('{') { // `.header {` => `
` class := line.find_between('.', '{').trim_space() + trimmed := line.trim_space() + source.write_string(strings.repeat(`\t`, line.len - trimmed.len)) // add the necessary indent to keep
code clean source.writeln('
') } else if state == .html && line.starts_with('#') && line.ends_with('{') { // `#header {` => `