Wire import
You can import snippets of another wire file into your wire file that you are creating or editing. This enables the re-use of wire code snippets across multiple wires, which can save time.
Before importing snippets from another wire into your current wire, you must first add the other wire as a resource file for your current wire.
Tag options
Block level
<datasources import="data.wire"/>
Object tag
<panel name="main" alias="MAIN" width="100%" height="100%" import="panel.wire"></panel>
Attributes
Import is an attribute that can live on any object or block level tag. Imports are done using an <import> tag.
Extends
None
Requirements
The import tag is versatile because you can place it in any object level tag inside of your main.wire, but you need to keep the following requirements in mind:
-
The contents of an imported wire must be compatible with the parent of the import tag. Most tags have a limit of compatible child tags and may not allow nesting with certain tag types. For example, you cannot nest global tags as duplicates of, or within, themselves, such as an import that results in a <main> tag inside of another <main> tag. The contents of an imported wire snippet are not verified during publishing.
-
The value of an import attribute must always be the name of an existing .wire or .xml file in your project.
-
The name of the import file must be referenced in an import tag by name and extension.
-
You can maintain the standard file naming convention of .wire, or you can name the import wire as .import, .actions or .styles, etc. (Note: The editor will not open a file unless its extension is .wire or .xml).
-
When you use an import on an object, and subsequently add more code as a child of the import object, the imported wire will always be rendered first and the children living in the main.wire are below the imported code in the z-order.
-
You can nest import attributes inside of import wires to call other import wires, but the same rules apply, where the import object needs to match the root level of the import Wire it is calling.
-
To import several wires for different sets of actions, place an import attribute on a platform tag inside of your actions block. You are not required to define a device, but you must use a platform tag as the root of your import wire.
-
An import attribute placed on an object that you build with a create tag will not render.
Sample code
Main wire content:
Imported wire content: "Import_DSCLSS" wire content
---main.wire---- <wire> <main> <panel name="import1" alias="IMP1" width="100%" height="50%" valign="top <import file="Import_Test.wire"/> </panel> <panel name="import2" alias="IMP2" height="50" width="100" bottomof="IMP1"> <list name="table" width="100%" height="80%" datasource="wiredrss" bottomof="title" orientation="vertical" paginate="no"> <object name="[ds:dataSourceIndex]" class="rssitem" title=[ds:title]" description="[ds:description]" description="[ds:description]" lhs=[ds:dataSourceIndex]" operator="lt" rhs="15"/> </list> </panel> </main> <actions> <action name="wire-exit"> <event type="exit"/> </action> </actions> </wire>
Imported wire content: "Import_Test" wire content
<datasources> <datasource name="wiredrss" source="http://feeds.reuters.com/reuters/technolotyNews" providertype="xml" query="//item" parsenamespaces="yes" /> </datasources> <classes> <class name="rssitem"> <panel name="[param:name]" alias="FRAME" background="#000000" height="70%" width="100%"> <text name="title" text="[param:title]" size="20" width="100%" height="25%" background="#FFFFF" color="#000000" /> <text name="description" text="[param:description]" size="14" width="100%" height="75%" background="#fffff" color="#000000" valight="bottom" /> </panel> </class> </classes>
<panel name="panel" width="100%" height="100%" background="#000ff" onclickup="wire-exit"> <text name="success" height="100%" width="100%" font="Helvetica" size="20" align="center" text="SUCCESS!"/>
Loading...
There was a problem loading this topic