1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

vfmt: change all '$expr' to '${expr}' (#16428)

This commit is contained in:
yuyi
2022-11-15 21:53:13 +08:00
committed by GitHub
parent 56239b4a23
commit 017ace6ea7
859 changed files with 7156 additions and 7135 deletions

View File

@ -141,8 +141,8 @@ fn (mut dom DocumentObjectModel) construct(tag_list []&Tag) {
dom.print_debug("Added ${tag.name} as child of '" + tag_list[temp_int].name +
"' which now has ${dom.btree.get_children().len} childrens")
*/
dom.print_debug("Added $tag.name as child of '" + temp_tag.name +
"' which now has $temp_tag.children.len childrens")
dom.print_debug("Added ${tag.name} as child of '" + temp_tag.name +
"' which now has ${temp_tag.children.len} childrens")
} else { // dom.new_root(tag)
stack.push(root_index)
}

View File

@ -6,8 +6,8 @@ fn generate_temp_html() string {
mut temp_html := strings.new_builder(200)
temp_html.write_string('<!doctype html><html><head><title>Giant String</title></head><body>')
for counter := 0; counter < 4; counter++ {
temp_html.write_string("<div id='name_$counter' ")
temp_html.write_string("class='several-$counter'>Look at $counter</div>")
temp_html.write_string("<div id='name_${counter}' ")
temp_html.write_string("class='several-${counter}'>Look at ${counter}</div>")
}
temp_html.write_string('</body></html>')
return temp_html.str()

View File

@ -123,7 +123,7 @@ pub fn (mut parser Parser) split_parse(data string) {
} else if is_quote {
parser.lexical_attributes.open_string = string_code
} else if chr == `>` { // only execute verification if is a > // here will verify < to know if code tag is finished
name_close_tag := '</$parser.lexical_attributes.opened_code_type>'
name_close_tag := '</${parser.lexical_attributes.opened_code_type}>'
if parser.builder_str().to_lower().ends_with(name_close_tag) {
parser.lexical_attributes.open_code = false
// need to modify lexeme_builder to add script text as a content in next loop (not gave error in dom)

View File

@ -25,7 +25,7 @@ fn test_giant_string() {
mut parser := Parser{}
temp_html.write_string('<!doctype html><html><head><title>Giant String</title></head><body>')
for counter := 0; counter < 2000; counter++ {
temp_html.write_string("<div id='name_$counter' class='several-$counter'>Look at $counter</div>")
temp_html.write_string("<div id='name_${counter}' class='several-${counter}'>Look at ${counter}</div>")
}
temp_html.write_string('</body></html>')
parser.parse_html(temp_html.str())
@ -35,7 +35,7 @@ fn test_giant_string() {
fn test_script_tag() {
mut parser := Parser{}
script_content := "\nvar googletag = googletag || {};\ngoogletag.cmd = googletag.cmd || [];if(3 > 5) {console.log('Birl');}\n"
temp_html := '<html><body><script>$script_content</script></body></html>'
temp_html := '<html><body><script>${script_content}</script></body></html>'
parser.parse_html(temp_html)
assert parser.tags[2].content.len == script_content.replace('\n', '').len
}

View File

@ -47,11 +47,11 @@ pub fn (tag Tag) text() string {
pub fn (tag &Tag) str() string {
mut html_str := strings.new_builder(200)
html_str.write_string('<$tag.name')
html_str.write_string('<${tag.name}')
for key, value in tag.attributes {
html_str.write_string(' $key')
html_str.write_string(' ${key}')
if value.len > 0 {
html_str.write_string('="$value"')
html_str.write_string('="${value}"')
}
}
html_str.write_string(if tag.closed && tag.close_type == .in_name { '/>' } else { '>' })
@ -62,7 +62,7 @@ pub fn (tag &Tag) str() string {
}
}
if !tag.closed || tag.close_type == .new_tag {
html_str.write_string('</$tag.name>')
html_str.write_string('</${tag.name}>')
}
return html_str.str()
}