blob: 165dc249fd2b373715d15be676bc1d87554e7df8 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
String concatenation
====================
Could skip standard string concatenation (it doesn't work well with memory
allocation anyway), and use template strings and string builders for that
purpose.
String id = get_id void
String button_html = make_button_html void
StringBuilder sb = t"<div id={id}>"
sb.append message
sb.append "<br>Message length: {length message}"
sb.append_with_unchecked t"{button_html:raw}"
sb.append t"</div>"
return sb.to_html_string # <-- extension method
Pure string builder, with no escape handling:
StringBuilder sb = "<a"
sb.append " rel=nofollow"
sb.append " href=https://example.com/"
sb.append ">"
return sb.to_raw_unchecked_string
# or
return sb.to_ascii_printable_string
|