TagCompiler-1.0/TagData

From WowAce Wiki
Jump to: navigation, search


Warning: Initial incomplete documentation

Tag Data describes how to convert a tag into the data it represents in a tag string.

Every tag must provide one of tableData, string, method, or compileString

tableData

string - assumes the tag parameter is a table, and accesses its field

Example

local tagData = { test = { tableData = "value" } }
local parameter = { value = 10 }
TagCompiler:Evaluate("Value is [test]", tagData, "string", parameter) -- returns "Value is 10"

string

string - the string that this tag is a substitute for

Example

tagData.Black = { string = "HexColor(\"000000\")" }

method

function(tagParameter, prior, ...) - a method that is called to determine that tag component at execution time.

Example

local tagData = 
{ 
 Upper = { method = function(tagParameter, prior) return prior:upper() end },
 Name =  { method = function(tagParameter) return UnitName(tagParameter) end }
}
TagCompiler:Evaluate("Test [name:upper]", tagData, "string", "player") -- returns "Test " followed by your player name in upper case

compileString

function(compileData, priorFunctionString, ...) - a method that is called to determine that tag component at compile time.

Example

local tagData = 
{ 
 Upper = { method = function(tagParameter, prior) return prior:upper() end },
 Name =  { compileString = function(compileData) return "UnitName(data)" end }
}
TagCompiler:Evaluate("Test [name:upper]", tagData, "string", "player") -- returns "Test " followed by your player name in upper case

Remarks

The string returned is inserted directly into the compile. "data" is the tagParameter passed in to :Evaluate(tagParameter) or :Compile(...).method(tagParameter)