Glyph - Macro Composition

Glyph macros can be composed with other using the / character. Macro composition can be used instead of nesting, provided that macro containers (also called dispatchers in certain situations) take only one parameter and no attributes.

For example, the following code:

1?[
2  not[output?[pdf]]|
3  ...
4]

Can be written like this:

1?[
2  not/output?[pdf]|
3  ...
4]

In this case, the not macro was composed with the output? macro, thus removing one level of nesting.

Composition can be useful to simplify complex Glyph macro constructs, but also for macro dispatching. Currently, Glyph supports two dispatchers:

  • The s macro, used to call almost any method of the Ruby String class.
  • The xml macro, used to render raw XML tags.