library.getContents: Difference between revisions
Jump to navigation
Jump to search
m (Added new Category tag) |
m (Oops, it's "source" that should be replaced with "syntaxhighlight") |
||
Line 10: | Line 10: | ||
|usage= | |usage= | ||
< | <syntaxhighlight lang="mtmacro" line> | ||
library.getContents(namespace) | library.getContents(namespace) | ||
</ | </syntaxhighlight > | ||
'''Parameters''' | '''Parameters''' | ||
{{param|namespace|Namespace for the library.}} | {{param|namespace|Namespace for the library.}} | ||
Line 18: | Line 18: | ||
|example= | |example= | ||
Get content information for the specified library. | Get content information for the specified library. | ||
< | < syntaxhighlight lang="mtmacro" line> | ||
<pre>[r: json.indent(library.getContents("net.rptools.addon.some-lib"),2)]</pre> | <pre>[r: json.indent(library.getContents("net.rptools.addon.some-lib"),2)]</pre> | ||
</ | </syntaxhighlight > | ||
Returns: | Returns: | ||
Output from a {{code|.mtlib}} library: | Output from a {{code|.mtlib}} library: | ||
< | < syntaxhighlight lang="JSON"> | ||
[ | [ | ||
"mtscript/public/auto_exec.mts", | "mtscript/public/auto_exec.mts", | ||
Line 39: | Line 39: | ||
"mtscript/public/myUDF.mts" | "mtscript/public/myUDF.mts" | ||
] | ] | ||
</ | </syntaxhighlight > | ||
|also= | |also= |
Revision as of 04:21, 11 February 2024
library.getContents() Function
Note: This function can only be used in a Trusted Macro
• Introduced in version 1.11.0
Retrieves a list of the content in the specified Add-On library. Information is returned as a JSON array.
- For
.mtlib
Add-On libraries this will include a list of all MTScript, HTML, JavaScript and CSS files, - For lib:token Add-On libraries this will include a list of all macros and all defined Token Properties.
Usage
library.getContents(namespace)
Parameters
namespace
- Namespace for the library.
Example
Get content information for the specified library.
< syntaxhighlight lang="mtmacro" line>
[r: json.indent(library.getContents("net.rptools.addon.some-lib"),2)]
</syntaxhighlight >
Returns:
Output from a .mtlib
library:
< syntaxhighlight lang="JSON">
[
"mtscript/public/auto_exec.mts", "mtscript/public/test1.mts", "public/test2.html", "mtscript/priv1.mts", "mtscript/public/test2.mts", "public/test1.html", "mtscript/public/CSSTest.mts", "mtscript/public/call_priv1.mts", "public/test-img.png", "mtscript/public/no_auto_exec.mts", "public/test1.css", "public/test1.js", "mtscript/public/myUDF.mts"
]
</syntaxhighlight >See Also
Version Changes
- 1.11.0 - Function added