Module: Eggshell::MacroHandler

Overview

Macros are extensible functions that can do a lot of things:

  • include other Eggshell documents into current document

  • process part of a document into a variable

  • do conditional processing

  • do loop processing

  • etc.

A typical macro call looks like this: ‘@macro(param, param, …)` and must be the first item on the line (excluding whitespace).

If a macro encloses a chunk of document, it would generally look like this:

pre. @block_macro(param, …) misc content misc content

Defined Under Namespace

Modules: Defaults

Constant Summary collapse

COLLECT_NORMAL =
:collect_normal
COLLECT_RAW_MACRO =
:collect_raw_macro
COLLECT_RAW =
:collect_raw
CHAIN_NONE =
0
CHAIN_START =
1
CHAIN_CONTINUE =
2
CHAIN_END =
3

Instance Method Summary collapse

Methods included from ProcessHandler

#process

Methods included from BaseHandler

#set_processor

Instance Method Details

#chain_type(macro) ⇒ Object

If a sequence of macros are related by conditional execution (if/elsif/else, for instance), this provides a hint to the processor in how to group and evaluate the macros.

Returns:

  • Array In the form ‘[CHAIN_TYPE, MACRO_START]`



46
47
48
# File 'lib/eggshell/macro-handler.rb', line 46

def chain_type(macro)
	[CHAIN_NONE, nil]
end

#collection_type(macro) ⇒ Object

TODO:

needed?

Indicates how to process lines contained with in the macro. {COLLECT_NORMAL} continues to evaluate block and macro content. {COLLECT_RAW_MACRO} collects all lines as raw unless a macro is encountered. {COLLECT_RAW} collects all lines as raw, regardless of nested macros.



33
34
35
# File 'lib/eggshell/macro-handler.rb', line 33

def collection_type(macro)
	COLLECT_NORMAL
end