Text Variable Reference
Inserts the text value provided in the corresponding Text Variable or Text Variable (Multiline) placeholder, optionally applying the selected transformation.
Parameters
1️⃣ Field Title
The title of the corresponding Text Variable or Text Variable (Multiline) placeholder.
2️⃣ Transformation (default: None
)
There are predefined transformations:
- None: No transformation
- Start Upper Case:
hello world -> Hello world
- Start Lower Case:
HELLO WORLD -> hELLO WORLD
- Upper Case:
hello world -> HELLO WORLD
- Lower Case:
HELLO WORLD -> hello world
- Title Case:
hello world -> Hello World
- Sentence Case:
hello world! how are you? -> Hello world! How are you?
- Camel Case:
hello world -> helloWorld
- Pascal Case:
hello world -> HelloWorld
- Snake Case:
hello world -> hello_world
- Join Lines:
hello\nworld -> hello world
- Split Lines by Space:
hello world -> hello\nworld
- Sort Lines:
world\nhello -> hello\nworld
Syntax
{@variable-reference|First Name|Upper Case@}
This placeholder takes the value from the corresponding Text
Variable or Text Variable
(Multiline) placeholder with Field Title
equal
to First Name
and applies the Upper Case
transformation to it.
Notes
Alternatively, if you don't need transformations, you can reuse placeholders by just copy-pasting their generated code. E.g. if you paste Text Variable placeholder twice, you will have to enter text just once and the value will be automatically inserted in all places.
Use Cases
This placeholder is useful when you want to reuse a text variable value in multiple places in your snippets and optionally apply a transformation to it.
Example 1
You want to reuse the same name in different parts of your template, which requires the name to be in different formats.
Dear Supplier,
Could you please send us the most recent price list for {@text|Product|apples@}?
{@variable-reference|Product|Start Upper Case@} are in high demand and we need
to update our prices.
Best regards,
Purchasing Department
Example 2
You want to create a snippet that generates a template to test a class with the given name. In this case, usually you need to reuse the class name in different formats.
final class {@text|Class@}Tests: XCTestCase {
private var {@variable-reference|Class|Start Lower Case@}: {@variable-reference|Class|Start Upper Case@}!
override func setUp() {
super.setUp()
{@variable-reference|Class|Start Lower Case@} = {@variable-reference|Class|Start Upper Case@}()
}
}