Having a long XtScript codes in one block could be confusing and hard to manage especially on mobile device with small screen. That’s when the
include command come in handy.
We can load external XtScript file and use on our codes using
include command. XtScript file has
After we have included an XtScript file, the command and script written in the file will be executed and run normally.
We also can access the variable declared in the included XtScript file by adding
@ prefix to the variable name (e.g.
Learn XtScript Include from example
Include an XtScript file named “xtscript-include.xt” at /demo/ directory on this site.
<!--parser:xtscript--> # Include an XtScript file. The path is relative to this site directory include /demo/xtscript-include.xt # Use "@" prefix to access the variable in the included XtScript file print <p><b>I am playing games using my @$device</b></p> <!--/parser:xtscript-->
This is some parapraph from $text variable written in a file named “xtscript-include.xt” that located at /demo/ directory on the xtgem site.
I am playing games using my Tablet
Here is what is written inside the included XtScript file:
var $text = <p>This is some parapraph from \$text variable written in a file named "xtscript-include.xt" that located at <i>/demo/</i> directory on the xtgem site.</p> var $device = Tablet print $text