Skip to main content

Text Editing

The CLI tool includes a text editing mode, allowing users to edit templates in a text file format. This enables faster creation and modification of elements without relying solely on commands. However, this method is more error-prone, as it lacks built-in type and value validation.

Payter Recommends

Define elements initially with the CLI Tool, using text editing to adjust values of existing properties, or to copy an element such as a button and place that element in a different location.

To start the text-editing enter:

start-text-editing {folder_path}

This will enable file watching for this folder. Whenever a file is created or saved, the tool will attempt to parse the template and display it in the terminal. You can use the show-template command to view a human-readable version of your template. This provides a structured layout that aligns with the expected data content for the file.

Example of File Content

my-first-screen.json

{
"templateName":"my-first-screen",
"elements":[
{
"name":"title",
"value":"Title",
"y":60,
"width":320,
"height":40,
"colorRef":"title",
"label":{
"font":"OpenSans",
"fontSize":42,
"fontStyle":"BOLD",
"textAlignment":"CENTER"
}
},
{
"name":"Subtitle",
"value":"Subtitle",
"y":90,
"width":320,
"height":40,
"colorRef":"title",
"label":{
"font":"OpenSans",
"fontSize":36,
"fontStyle":"BOLD",
"textAlignment":"CENTER"
}
}
]
}

note

You can use any text editor to make changes, for example Notepad.

tip

You can create new templates as JSON files directly. Bear in mind that the template-name is set inside the file, and is not the filename. Payter supply the JSON files for our built-in screens in the Adapt Existing section for example.