tmpl: minor fixes and optimizations
parent
3388caa6c5
commit
9355048b6c
|
@ -256,30 +256,27 @@ fn vweb_tmpl_${fn_name}() string {
|
||||||
|
|
||||||
match state {
|
match state {
|
||||||
.html {
|
.html {
|
||||||
if line.starts_with('span.') && line.ends_with('{') {
|
line_t := line.trim_space()
|
||||||
|
if line_t.starts_with('span.') && line.ends_with('{') {
|
||||||
// `span.header {` => `<span class='header'>`
|
// `span.header {` => `<span class='header'>`
|
||||||
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
|
||||||
continue
|
continue
|
||||||
}
|
} else if line_t.starts_with('.') && line.ends_with('{') {
|
||||||
if 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()
|
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.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">')
|
||||||
continue
|
continue
|
||||||
}
|
} else if line_t.starts_with('#') && line.ends_with('{') {
|
||||||
if 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">')
|
||||||
continue
|
continue
|
||||||
}
|
} else if line_t == '}' {
|
||||||
if line.trim_space() == '}' {
|
source.write_string(strings.repeat(`\t`, line.len - line_t.len)) // add the necessary indent to keep <div><div><div> code clean
|
||||||
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
|
||||||
|
|
Loading…
Reference in New Issue