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:
@@ -70,7 +70,7 @@ fn (am AssetManager) combine(asset_type string, to_file bool) string {
|
||||
panic('vweb.assets: you must set a cache dir.')
|
||||
}
|
||||
cache_key := am.get_cache_key(asset_type)
|
||||
out_file := '$am.cache_dir/${cache_key}.$asset_type'
|
||||
out_file := '${am.cache_dir}/${cache_key}.${asset_type}'
|
||||
mut out := ''
|
||||
// use cache
|
||||
if os.exists(out_file) {
|
||||
@@ -114,7 +114,7 @@ fn (am AssetManager) get_cache_key(asset_type string) string {
|
||||
}
|
||||
}
|
||||
hash := md5.sum(files_salt.bytes()).hex()
|
||||
return '$hash-$latest_modified'
|
||||
return '${hash}-${latest_modified}'
|
||||
}
|
||||
|
||||
fn (am AssetManager) include(asset_type string, combine bool) string {
|
||||
@@ -123,19 +123,19 @@ fn (am AssetManager) include(asset_type string, combine bool) string {
|
||||
if asset_type == 'css' {
|
||||
if combine {
|
||||
file := am.combine(asset_type, true)
|
||||
return '<link rel="stylesheet" href="$file">\n'
|
||||
return '<link rel="stylesheet" href="${file}">\n'
|
||||
}
|
||||
for asset in assets {
|
||||
out += '<link rel="stylesheet" href="$asset.file_path">\n'
|
||||
out += '<link rel="stylesheet" href="${asset.file_path}">\n'
|
||||
}
|
||||
}
|
||||
if asset_type == 'js' {
|
||||
if combine {
|
||||
file := am.combine(asset_type, true)
|
||||
return '<script type="text/javascript" src="$file"></script>\n'
|
||||
return '<script type="text/javascript" src="${file}"></script>\n'
|
||||
}
|
||||
for asset in assets {
|
||||
out += '<script type="text/javascript" src="$asset.file_path"></script>\n'
|
||||
out += '<script type="text/javascript" src="${asset.file_path}"></script>\n'
|
||||
}
|
||||
}
|
||||
return out
|
||||
@@ -159,7 +159,7 @@ fn (mut am AssetManager) add(asset_type string, file string) bool {
|
||||
} else if asset_type == 'js' {
|
||||
am.js << asset
|
||||
} else {
|
||||
panic('$assets.unknown_asset_type_error ($asset_type).')
|
||||
panic('${assets.unknown_asset_type_error} (${asset_type}).')
|
||||
}
|
||||
return true
|
||||
}
|
||||
@@ -176,7 +176,7 @@ fn (am AssetManager) exists(asset_type string, file string) bool {
|
||||
|
||||
fn (am AssetManager) get_assets(asset_type string) []Asset {
|
||||
if asset_type != 'css' && asset_type != 'js' {
|
||||
panic('$assets.unknown_asset_type_error ($asset_type).')
|
||||
panic('${assets.unknown_asset_type_error} (${asset_type}).')
|
||||
}
|
||||
assets := if asset_type == 'css' { am.css } else { am.js }
|
||||
return assets
|
||||
|
||||
@@ -124,7 +124,7 @@ fn test_include_css() {
|
||||
mut am := assets.new_manager()
|
||||
file1 := get_test_file_path('test1.css')
|
||||
am.add_css(file1)
|
||||
expected := '<link rel="stylesheet" href="$file1">\n'
|
||||
expected := '<link rel="stylesheet" href="${file1}">\n'
|
||||
actual := am.include_css(false)
|
||||
assert actual == expected
|
||||
assert actual.contains(expected)
|
||||
@@ -133,7 +133,7 @@ fn test_include_css() {
|
||||
am.add_css(file2)
|
||||
am.cache_dir = cache_dir('test_include_css')
|
||||
clean_cache_dir(am.cache_dir)
|
||||
expected2 := expected + '<link rel="stylesheet" href="$file2">\n'
|
||||
expected2 := expected + '<link rel="stylesheet" href="${file2}">\n'
|
||||
actual2 := am.include_css(false)
|
||||
assert actual2 == expected2
|
||||
assert actual2.contains(expected2)
|
||||
@@ -141,7 +141,7 @@ fn test_include_css() {
|
||||
clean_cache_dir(am.cache_dir)
|
||||
actual3 := am.include_css(true)
|
||||
assert actual3.contains(expected2) == false
|
||||
assert actual3.starts_with('<link rel="stylesheet" href="$am.cache_dir/') == true
|
||||
assert actual3.starts_with('<link rel="stylesheet" href="${am.cache_dir}/') == true
|
||||
// Test cache path doesn't change when input files and minify setting do not.
|
||||
clean_cache_dir(am.cache_dir)
|
||||
actual4 := am.include_css(true)
|
||||
@@ -153,7 +153,7 @@ fn test_include_js() {
|
||||
mut am := assets.new_manager()
|
||||
file1 := get_test_file_path('test1.js')
|
||||
am.add_js(file1)
|
||||
expected := '<script type="text/javascript" src="$file1"></script>\n'
|
||||
expected := '<script type="text/javascript" src="${file1}"></script>\n'
|
||||
actual := am.include_js(false)
|
||||
assert actual == expected
|
||||
assert actual.contains(expected)
|
||||
@@ -162,7 +162,7 @@ fn test_include_js() {
|
||||
am.add_js(file2)
|
||||
am.cache_dir = cache_dir('test_include_js')
|
||||
clean_cache_dir(am.cache_dir)
|
||||
expected2 := expected + '<script type="text/javascript" src="$file2"></script>\n'
|
||||
expected2 := expected + '<script type="text/javascript" src="${file2}"></script>\n'
|
||||
actual2 := am.include_js(false)
|
||||
assert actual2 == expected2
|
||||
assert actual2.contains(expected2)
|
||||
@@ -170,7 +170,7 @@ fn test_include_js() {
|
||||
clean_cache_dir(am.cache_dir)
|
||||
actual3 := am.include_js(true)
|
||||
assert actual3.contains(expected2) == false
|
||||
assert actual3.starts_with('<script type="text/javascript" src="$am.cache_dir/')
|
||||
assert actual3.starts_with('<script type="text/javascript" src="${am.cache_dir}/')
|
||||
// Test cache path doesn't change when input files and minify setting do not.
|
||||
clean_cache_dir(am.cache_dir)
|
||||
actual4 := am.include_js(true)
|
||||
|
||||
Reference in New Issue
Block a user