vweb: simplify @foo by removing V_TEMPLATE rule

master
Alexander Medvednikov 2022-05-14 17:46:26 +03:00
parent f0d46413d9
commit b42c824cdb
2 changed files with 9 additions and 9 deletions

View File

@ -287,13 +287,13 @@ fn vweb_tmpl_${fn_name}() string {
}
}
.js {
if line.contains('//V_TEMPLATE') {
source.writeln(insert_template_code(fn_name, tmpl_str_start, line))
} 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"\'"))
}
// if line.contains('//V_TEMPLATE') {
source.writeln(insert_template_code(fn_name, tmpl_str_start, line))
//} 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"\'"))
//}
continue
}
.css {

View File

@ -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')