Sha256: 8685194b1715e7167d6165f85cf62a356a6837208f6ae34bf473e8a3292d7c9d

Contents?: true

Size: 787 Bytes

Versions: 4

Compression:

Stored size: 787 Bytes

Contents

txt[
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:
]
highlight[=html|
?[
  not[output?[pdf]]\|
  ...
]
=]

p[Can be written like this:]

highlight[=html|
?[
  not/output?[pdf]\|
  ...
]
=]

txt[
In this case, the %>[not] was composed with the %>[output?], 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], used to call almost any method of the Ruby String class.
* The %>[xml], used to render raw XML tags.
]

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
glyph-0.5.3.1 book/text/text_editing/macro_composition.glyph
glyph-0.5.2 book/text/text_editing/macro_composition.glyph
glyph-0.5.1 book/text/text_editing/macro_composition.glyph
glyph-0.5.0 book/text/text_editing/macro_composition.glyph