diff --git a/examples/vweb/index.html b/examples/vweb/index.html index d69ff78733..736f8d643a 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 796da60e42..8bb8cda75f 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 {` => `