eggshell 0.8.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,41 @@
1
+ # Macros are extensible functions that can do a lot of things:
2
+ #
3
+ # - include other Eggshell documents into current document
4
+ # - process part of a document into a variable
5
+ # - do conditional processing
6
+ # - do loop processing
7
+ # - etc.
8
+ #
9
+ # A typical macro call looks like this: `@macro(param, param, ...)` and
10
+ # must be the first item on the line (excluding whitespace).
11
+ #
12
+ # If a macro encloses a chunk of document, it would generally look like
13
+ # this:
14
+ #
15
+ # pre. @block_macro(param, ...)
16
+ # misc content
17
+ # misc content
18
+ # @end_block_macro
19
+ #
20
+ #
21
+ module Eggshell::MacroHandler
22
+ def set_processor(proc)
23
+ end
24
+
25
+ def process(buffer, macname, args, lines, indent)
26
+ end
27
+
28
+ module Defaults
29
+ class NoOpHandler
30
+ include Eggshell::MacroHandler
31
+
32
+ def set_processor(proc)
33
+ @proc = proc
34
+ end
35
+
36
+ def process(buffer, macname, args, lines, indent)
37
+ @proc._warn("couldn't find macro: #{macname}")
38
+ end
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,28 @@
1
+ # Holds things like variables, line/char count, and other useful information for a {{Processor}} instance.
2
+ class Eggshell::ProcessorContext
3
+ def initialize
4
+ @vars = {:references => {}, :toc => [], :include_paths => [], 'log.level' => '1'}
5
+ @funcs = {}
6
+ @macros = {}
7
+ @blocks = {}
8
+ @block_params = {}
9
+ @expr_cache = {}
10
+
11
+ # keeps track of line counters based on include
12
+ @lcounters = [Eggshell::LineCounter.new]
13
+ end
14
+
15
+ attr_reader :vars, :funcs, :macros, :blocks, :block_params, :expr_cache
16
+
17
+ def push_line_counter
18
+ @lcounters << Eggshell::LineCounter.new
19
+ end
20
+
21
+ def pop_line_counter
22
+ @lcounters.pop
23
+ end
24
+
25
+ def line_counter
26
+ @lcounters[-1]
27
+ end
28
+ end