Cold Help System: Building: CML: Customizing Ctext


Interface

Ctext frobs are created by calling the .compile_cml() method off the cml compiler object. On a ctext frob, you may call .uncompile() to return the original text. A call to .eval_ctext() evaluates the generators, but will not touch the formatters. This is used to speed up message dispatching. Calling format() provides the final formatting of the ctext, evaluating everything, including the formatters. You can add/modify variables on a ctext frob by calling .set_var(variable, value), or .set_vars(dict), which does the same, but assigning multiple variables at once.

Adding new evaluators

An evaluator is an object which contains methods for generation or formatting. An evaluation object that is descended from a vanilla evaluator (like $bs_eval) will try to store the evaluation results in a list, and is therefore most suitable for adding new generators. On the other hand, evaluators descended from a formatter object create a string, and try to evaluate and concatenate lists until a string is obtained. Hence, they should be used for formatting. To add a new generator or formatter, simply add a do_format or gen_generator method on the object, where 'format' or 'generator' is the name of the new tag that you wish to add. Make sure that the object is in the evaluation path (by explicitly adding an 'evaluator, 'formatter or even an 'uncompiler field to the ctext frob.)


Formatters | Generators | Customizing Ctext


the Cold Dark