result = db.query("{} SELECT name, id FROM users WHERE name LIKE '{ encodeSql(request.userMask) }%' LIMIT {request.page * xPageSize}, {xPageSize}; "); request.mode == Json ? response.send(result.toJson()) : response.send("{} <ul>{ result.forRecords((record) { "{} <li data-id="{ record["id"] }"> { record["name"] } </li> "}) }</ul> ")
In this example we use string interpolation twice:
- to build an SQL query
- to convert query results to HTML
This SQL query is a simple multiline text string with { placeholders } . Placeholders are Argentum expressions that return everything convertible to strings.
HTML example demonstrates two nested interpolated strings - one for <ul> and one for nested <li>s.
More on string interpolation: here.
Discussions
Become a Hackaday.io Member
Create an account to leave a comment. Already have an account? Log In.