vweb: simplify @foo by removing V_TEMPLATE rule
parent
f0d46413d9
commit
b42c824cdb
|
@ -287,13 +287,13 @@ fn vweb_tmpl_${fn_name}() string {
|
|||
}
|
||||
}
|
||||
.js {
|
||||
if line.contains('//V_TEMPLATE') {
|
||||
// if line.contains('//V_TEMPLATE') {
|
||||
source.writeln(insert_template_code(fn_name, tmpl_str_start, line))
|
||||
} else {
|
||||
//} else {
|
||||
// replace `$` to `\$` at first to escape JavaScript template literal syntax
|
||||
source.writeln(line.replace(r'$', r'\$').replace(r'$$', r'@').replace(r'.$',
|
||||
r'.@').replace(r"'", r"\'"))
|
||||
}
|
||||
// source.writeln(line.replace(r'$', r'\$').replace(r'$$', r'@').replace(r'.$',
|
||||
// r'.@').replace(r"'", r"\'"))
|
||||
//}
|
||||
continue
|
||||
}
|
||||
.css {
|
||||
|
|
|
@ -20,8 +20,8 @@ fn test_template_interpolation_can_be_selectively_turned_on_in_script_tags() {
|
|||
text := $tmpl('tmpl/selective_interpolation_in_script_tag.html')
|
||||
dump(text)
|
||||
assert text.contains('Username: abcd')
|
||||
assert text.contains('var non_interpolated_labels = @benchmark_plot_data.dates;')
|
||||
assert text.contains('var non_interpolated_values = @benchmark_plot_data.numerical_result;')
|
||||
assert text.contains('var non_interpolated_labels = ['2012-11-30', '2022-12-29'];')
|
||||
assert text.contains('var non_interpolated_values = [5, 6, 7, 1];')
|
||||
assert text.contains("var real_labels = ['2012-11-30', '2022-12-29']; //V_TEMPLATE")
|
||||
assert text.contains('var real_values = [5, 6, 7, 1]; //V_TEMPLATE')
|
||||
assert text.contains('Year: 2022')
|
||||
|
|
Loading…
Reference in New Issue