tmpl: enforce stricter line checking for html interpolation (#11413)
parent
bd10a63839
commit
905c292a81
|
@ -193,16 +193,16 @@ mut sb := strings.new_builder($lstartlength)\n
|
|||
pos := line.index('@for') or { continue }
|
||||
source.writeln('for ' + line[pos + 4..] + '{')
|
||||
source.writeln(parser.tmpl_str_start)
|
||||
} else if state == .html && line.contains('span.') && line.ends_with('{') {
|
||||
} else if state == .html && line.starts_with('span.') && line.ends_with('{') {
|
||||
// `span.header {` => `<span class='header'>`
|
||||
class := line.find_between('span.', '{').trim_space()
|
||||
source.writeln('<span class="$class">')
|
||||
in_span = true
|
||||
} else if state == .html && line.contains('.') && line.ends_with('{') {
|
||||
} else if state == .html && line.starts_with('.') && line.ends_with('{') {
|
||||
// `.header {` => `<div class='header'>`
|
||||
class := line.find_between('.', '{').trim_space()
|
||||
source.writeln('<div class="$class">')
|
||||
} else if state == .html && line.contains('#') && line.ends_with('{') {
|
||||
} else if state == .html && line.starts_with('#') && line.ends_with('{') {
|
||||
// `#header {` => `<div id='header'>`
|
||||
class := line.find_between('#', '{').trim_space()
|
||||
source.writeln('<div id="$class">')
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
This is the main content:
|
||||
-------------------------
|
||||
@content
|
||||
Name: @{p1.name}
|
||||
-------------------------
|
||||
|
||||
@include './footer.md'
|
||||
|
|
|
@ -3,6 +3,7 @@ my header
|
|||
This is the main content:
|
||||
-------------------------
|
||||
some string
|
||||
Name: Peter
|
||||
-------------------------
|
||||
|
||||
my footer
|
||||
|
|
|
@ -1,4 +1,11 @@
|
|||
struct Person {
|
||||
mut:
|
||||
name string
|
||||
}
|
||||
|
||||
fn abc() string {
|
||||
mut p1 := Person{}
|
||||
p1.name = 'Peter'
|
||||
content := 'some string'
|
||||
return $tmpl('file.md')
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue