tmpl: fix <div> inside <div>
parent
b2ecca3966
commit
f6bdc6b87e
|
@ -1,11 +1,19 @@
|
||||||
|
@include 'header.html'
|
||||||
|
|
||||||
Test <b>app</b>
|
Test <b>app</b>
|
||||||
<br>
|
<br>
|
||||||
<h1>@hello</h1>
|
<h1>@hello</h1>
|
||||||
<hr>
|
<hr>
|
||||||
|
|
||||||
|
If demo: <br>
|
||||||
@if show
|
@if show
|
||||||
show = true
|
show = true
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
<br><br>
|
||||||
|
|
||||||
|
For loop demo: <br>
|
||||||
|
|
||||||
@for number in numbers
|
@for number in numbers
|
||||||
@number <br>
|
@number <br>
|
||||||
@end
|
@end
|
||||||
|
|
|
@ -198,15 +198,19 @@ mut sb := strings.new_builder($lstartlength)\n
|
||||||
class := line.find_between('span.', '{').trim_space()
|
class := line.find_between('span.', '{').trim_space()
|
||||||
source.writeln('<span class="$class">')
|
source.writeln('<span class="$class">')
|
||||||
in_span = true
|
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 {` => `<div class='header'>`
|
// `.header {` => `<div class='header'>`
|
||||||
class := line.find_between('.', '{').trim_space()
|
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 <div><div><div> code clean
|
||||||
source.writeln('<div class="$class">')
|
source.writeln('<div class="$class">')
|
||||||
} else if state == .html && line.starts_with('#') && line.ends_with('{') {
|
} else if state == .html && line.starts_with('#') && line.ends_with('{') {
|
||||||
// `#header {` => `<div id='header'>`
|
// `#header {` => `<div id='header'>`
|
||||||
class := line.find_between('#', '{').trim_space()
|
class := line.find_between('#', '{').trim_space()
|
||||||
source.writeln('<div id="$class">')
|
source.writeln('<div id="$class">')
|
||||||
} else if state == .html && line == '}' {
|
} else if state == .html && line.trim_space() == '}' {
|
||||||
|
trimmed := line.trim_space()
|
||||||
|
source.write_string(strings.repeat(`\t`, line.len - trimmed.len)) // add the necessary indent to keep <div><div><div> code clean
|
||||||
if in_span {
|
if in_span {
|
||||||
source.writeln('</span>')
|
source.writeln('</span>')
|
||||||
in_span = false
|
in_span = false
|
||||||
|
|
|
@ -0,0 +1,5 @@
|
||||||
|
<b>embedded</b>
|
||||||
|
|
||||||
|
.embedded {
|
||||||
|
hello
|
||||||
|
}
|
|
@ -35,8 +35,13 @@ const classes = `header ${ isLargeScreen() ? '' :
|
||||||
<h1>@{title}</h1>
|
<h1>@{title}</h1>
|
||||||
<p>@title</p>
|
<p>@title</p>
|
||||||
.hello {
|
.hello {
|
||||||
<b>hi</b><br>
|
.hello2 {
|
||||||
|
<b>hi</b><br>
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@include 'embedded.html'
|
||||||
|
|
||||||
<a href="@website.link">@website.link</a>
|
<a href="@website.link">@website.link</a>
|
||||||
<a href="mailto:example@@@website.link">Email</a>
|
<a href="mailto:example@@@website.link">Email</a>
|
||||||
</header>
|
</header>
|
||||||
|
|
|
@ -35,8 +35,17 @@ const classes = `header ${ isLargeScreen() ? '' :
|
||||||
<h1>TEST</h1>
|
<h1>TEST</h1>
|
||||||
<p>TEST</p>
|
<p>TEST</p>
|
||||||
<div class="hello">
|
<div class="hello">
|
||||||
<b>hi</b><br>
|
<div class="hello2">
|
||||||
|
<b>hi</b><br>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<b>embedded</b>
|
||||||
|
|
||||||
|
<div class="embedded">
|
||||||
|
hello
|
||||||
|
</div>
|
||||||
|
|
||||||
<a href="example.com">example.com</a>
|
<a href="example.com">example.com</a>
|
||||||
<a href="mailto:example@example.com">Email</a>
|
<a href="mailto:example@example.com">Email</a>
|
||||||
</header>
|
</header>
|
||||||
|
|
Loading…
Reference in New Issue