Sha256: f107967b79697ae87ed64594e5827901e6b206c2d0d8716492a6bea6fef768b4

Contents?: true

Size: 1.06 KB

Versions: 3

Compression:

Stored size: 1.06 KB

Contents

	txt[
Although a macro can take any number of parameters, they are often no more than two or three, for readibility reasons: parameters have no name, but their position within a macro is significant.

If you have something like this:
	]

	highlight[=html|custom_image[test.png\|50%\|50%\|Test Image]=]
	txt[
it may still be easy enough to understand what each parameter is used for, but:
* you can easily forget that the third parameter is the image width
* if you don't want to resize the image, you still have to pass _empty parameters_ to the macro, like this: code[=custom_image[test2.png\|\|\|Test Image]=]

To avoid these situations, some macros which would normally take three or four parameters take optional attributes instead, so you can write:
	]
	highlight[=html|
image[test.png
  @width[50%]
  @alt[Test Image]
  @height[50%]
]=]
	p[More verbose, of course, but definitely more readable. In this way, if you won't want to scale an image, you can safely omit the code[@width] and code[@height] attributes.]
	note[Like parameters, attributes can contain other macros, too.]

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
glyph-0.4.2 book/text/text_editing/attribute_intro.glyph
glyph-0.4.1 book/text/text_editing/attribute_intro.glyph
glyph-0.4.0 book/text/text_editing/attribute_intro.glyph