Working with data
There’s lots of ways to work with real data in Skala, ranging from easy and manual, to fully automated. The easy methods typically mean using Skala’s constants. The automated methods typically involve scripting or writing code to generate documents or images.
They’re all good approaches. The one that’s right for you will depend on your requirements.
Manually editing constants #
Constants can be used for practically anything in Skala. For example, it’s possible to set up a design for a weather app, where the observed temperature across a wide range of components references a single constant. Doing so lets you change a single value to update many components with the current temperature.
Importing and exporting constants #
Constants can be imported into and exported from Skala, using the options button at the top of the constants table in the document properties tab. This allows different sets of constants to be manually loaded in as required. Constants are exported as JSON files, so they can be opened in a text editor, or generated by code. When importing, constants with matching names replace the ones already in the document.
For example, if a Skala document was set up entirely using string constants, it would be possible to import a new JSON file to switch the design to another language. This would also let team members edit the text without needing Skala. Or, expanding on the previous example, a script could be created to fetch the current weather conditions, saving them to an appropriately formatted JSON file to load into Skala, updating a design.
Further reading: Constants, which describes the JSON format
Constants in Skala documents #
Importing new sets of constants works, but it’s a manual process. Directly editing Skala documents via scripting can batch update constants in lots of documents at once. For further examples, please take a look at the scripting page.
When a Skala document used as a component changes on disk, it will be updated within Skala documents that reference it. And, if an open Skala document is changed on disk and hasn’t been edited in Skala since it was last saved, Skala reloads it.
Generating Skala documents #
Rather than just updating constants within a Skala document, entire documents or components can be generated. This opens up even more opportunities, like creating detailed graphs using freeform paths. And, because Skala components are separate files, the dynamic portion of the design you’d like to generate with code can be separated from the rest of the design.
Using Skala’s MCP server is a good way to do this.
Generating images #
When an image used as an image layer changes on disk, the image will be updated within Skala documents. If you wanted to design something that contained the top 50 podcast artwork images, you’d just need to write code to update the images being referenced by a Skala document, or ask a friendly developer to help you.