OpenLaszloのソースコードは1ファイルで完結できますが、複数のファイルに分割することもできます。<include>タグを使うと、他のファイルの内容をインクルードできます。
<include>には3種類の使い方があります:
href属性でインクルードするファイル名を指定します。ファイル名やディレクトリなどに特に制約はありません。
myWindow.lzxという別ファイルをインクルードしています。
<?xml version="1.0" encoding="UTF-8"?> <canvas proxied="false" bgcolor="0xeeeeee"> <include href="myWindow.lzx"/> <myWindow/> <myWindow x="160"/> </canvas>
myWindow.lzx:
<?xml version="1.0" encoding="UTF-8"?> <library> <class name="myWindow" extends="window" title="ウインドウ" width="150" height="100"> <button>ボタン</button> </class> </library>
ファイルの中身が単に置換されているイメージですね。
<?xml version="1.0" encoding="UTF-8"?> <canvas proxied="false" bgcolor="0xeeeeee"> <window width="150" height="200" layout="axis:y"> <include href="myButton.lzx"/> <include href="myButton.lzx"/> <include href="myButton.lzx"/> <include href="myButton.lzx"/> <include href="myButton.lzx"/> </window> </canvas>
myButton.lzx:
<button>ボタン!</button>
<include>タグのtype属性でtextを指定すると、テキストファイル(XMLファイルではなく単なる文字列のファイル)をインクルードできます。
ファイルの中身が置換されているイメージです。
<?xml version="1.0" encoding="UTF-8"?> <canvas proxied="false" bgcolor="0xeeeeee"> <window width="200" height="100" layout="axis:y"> <text> <include href="myText.txt" type="text"/> </text> <button> <include href="myText.txt" type="text"/> </button> </window> </canvas>
myText.txt:
こんにちは。コンニチハ。