-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #13 from michaeljones/insert-string-builder
Introduce syntax for inserting string_builder values
- Loading branch information
Showing
8 changed files
with
185 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
--- | ||
source: src/main.rs | ||
assertion_line: 1201 | ||
expression: "Hello {[ name ]}, good to meet you" | ||
|
||
--- | ||
[ | ||
Text( | ||
"Hello ", | ||
), | ||
Builder( | ||
"name", | ||
), | ||
Text( | ||
", good to meet you", | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
--- | ||
source: src/main.rs | ||
assertion_line: 1298 | ||
expression: "Hello {[ name ]}, good to meet you" | ||
|
||
--- | ||
import gleam/string_builder.{StringBuilder} | ||
import gleam/list | ||
|
||
|
||
|
||
pub fn render_builder(name name) -> StringBuilder { | ||
let builder = string_builder.from_string("") | ||
let builder = string_builder.append(builder, "Hello ") | ||
let builder = string_builder.append_builder(builder, name) | ||
let builder = string_builder.append(builder, ", good to meet you") | ||
|
||
builder | ||
} | ||
|
||
pub fn render(name name) -> String { | ||
string_builder.to_string(render_builder(name: name)) | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
--- | ||
source: src/main.rs | ||
assertion_line: 1092 | ||
expression: "Hello {[ builder ]}, good to meet you" | ||
|
||
--- | ||
[ | ||
( | ||
Text( | ||
"Hello ", | ||
), | ||
0..6, | ||
), | ||
( | ||
OpenBuilder, | ||
6..7, | ||
), | ||
( | ||
Identifier( | ||
"builder", | ||
), | ||
9..16, | ||
), | ||
( | ||
CloseBuilder, | ||
17..18, | ||
), | ||
( | ||
Text( | ||
", good to meet you", | ||
), | ||
19..36, | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Hello {[ name_builder ]}, good to meet you |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters