TagCompiler-1.0
From WowAce Wiki
| Summary | |
|---|---|
| Lib: TagCompiler-1.0 | |
| A library to provide configuration via simple tag syntax | |
| TOC | 2.3 (20300) |
| Category | Libraries |
| Authors | Roartindon, Silvermoon |
| Details | |
| Version | 1.0 |
| Dependencies | Ace2 |
| Links | |
| Betas | Ace SVN Zip |
| Changelog | FishEye |
Contents |
Documentation is very very initial. More to come.
TagCompiler-1.0 is a library to provide tag based customization to addons. Each addon specifies which tags it handles, and what those tags mean, and TagCompiler generates an efficient function to realise the desired result.
Example
local tagData = { name = { compileString = function() return "UnitName(data)" end } }
local result = TagCompiler:Evaluate("Unit's name: [name]", tagData, "string", "player")
assert(result == "Unit's name: "..UnitName("player"))
API Documentation
:Compile(tag, tagData, resultType)
Compiles a tag and returns a table containing information about the compile.
Args
- tag
- The tag to compile
- tagData
- Information about the tags to be handled
- resultType
- One of "string", "number", or "raw"
Remarks
Example
:FixCasing(tag, tagData, resultType)
Cosmetic fixup of the tag to match the casing in tagData
Args
- tag
- The tag to compile
- tagData
- Information about the tags to be handled
- resultType
- One of "string", "number", or "raw"
Returns
string - The tag passed in with cases adjusted to how the casing is specified in tagData.
Remarks
This function is not required for proper operation. Calling it allows formatting of user-entered strings to provide a consistent appearance and increase chances of cache hits between multiple tags within the same addon.
:HighlightSyntax(tag, tagData, resultType)
Inserts color codes into tag strings for nicer display.
Args
- tag
- The tag to compile
- tagData
- Information about the tags to be handled
- resultType
- One of "string", "number", or "raw"
Returns
string - The tag passed in with colors adjusted
Remarks
If you use this function to color tags for input, make sure you remove the color codes before using the tag.
tag = tag:gsub("|c%x%x%x%x%x%x%x%x", ""):gsub("|r", "")
:Evaluate(tag, tagData, resultType, tagParameter)
Args
- tag
- The tag to compile
- tagData
- Information about the tags to be handled
- resultType
- One of "string", "number", or "raw"
- tagParameter
- Arbitrary user data passed into the tag's handlers. This can be a table, a string, or whatever your handlers are designed to work with.
Returns
The result of evaluating the tag. If resultType is string or number, then those are returned. Raw will return whatever the tag evaluates to, with no type coercion.

