-
Notifications
You must be signed in to change notification settings - Fork 4
Resources
A Resources file defines a number of re-usable portions of UI such as Templates and Fragments, or other resources such as Transforms or DataProviders. A Resources file can also import other Resources files, for reference within.
A Resources file is defined in YAML, and has the following top-level properties:
Type: resources
The file_type
helps YUI understand what kind of file it is looking at, and can help catch certain errors where you might refer to the wrong kind of file accidentally. A Resources file must always have file_type: resources
.
Type: Array of file path strings
The import
property allows you to import other resources and interactions for use by resources within the current Resources file. File paths are relative to the location of the current file, so you may need to prefix the path with ../
etc. if you need to import a file in a different folder than that of the current file. See Importing Resources for more details.
Type: resources map
The resources
property is where you define the resources for the Resources file. The value is a YAML map from a unique resource ID to the actual resource value. For example, you might define some re-usable fragments like so:
resources: hello_world_text: type: fragment content: type: text text: Hello World! exit_game_button: type: fragment content: type: button content: Exit Game on_click: handler: yui_log parameters: exit game clicked!
In this case hello_world_text
and exit_game_button
are the unique IDs for the two resources being defined.
How unique do the IDs need to be? Ultimately, the IDs need to be unique for every resources included in a single screen. However, since you'll likely share resources across screens, it's a good idea to keep the IDs unique across your whole project.
Home - Elements - Built-in Widgets - YuiScript - Themes -- Custom Widgets