markdown-expander 0.6.0 → 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +3 -3
- data/README.md.docu +3 -3
- data/lib/markdown-expander.rb +28 -24
- data/lib/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 61595a9cdbd9373019eccd421e379de6cda1edfb
|
4
|
+
data.tar.gz: 858f94a729be5106f0a260a6688503c9ea6fdf34
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c5b7813853e5fdf883c7d8c390b804500075f2c75e15a65811682f2a25c85725f76ef29708d1a04fff54c33a4157c93c41cb44622fbed838db5522302b7abf16
|
7
|
+
data.tar.gz: 0ac90bf8d84e868cc8821ecaf61c56d3d16ce9ba2a5f6279c2b0b0b94788a02188c5b0207988605bd9f0a0bfede7a5e806c1d7960516380a6529b83257915746
|
data/README.md
CHANGED
@@ -38,7 +38,7 @@ MarkdownExpander::Expander.new(
|
|
38
38
|
"# Title: {{thing.title}}"
|
39
39
|
).render(
|
40
40
|
thing: {title: "Hello"}
|
41
|
-
)
|
41
|
+
)
|
42
42
|
#=> "# Title: Hello"
|
43
43
|
```
|
44
44
|
|
@@ -55,7 +55,7 @@ TEMPLATE
|
|
55
55
|
|
56
56
|
MarkdownExpander::Expander.new(template).render(
|
57
57
|
stuff: [ {title: "First!"}, {title: "Second!"} ]
|
58
|
-
)
|
58
|
+
)
|
59
59
|
#=> "# First!\n# Second!\n"
|
60
60
|
```
|
61
61
|
|
@@ -74,6 +74,6 @@ TEMPLATE
|
|
74
74
|
|
75
75
|
MarkdownExpander::Expander.new(template).render(
|
76
76
|
animals: [ {name: "dogs"}, {name: "cats"} ]
|
77
|
-
)
|
77
|
+
)
|
78
78
|
#=> "# cats are the best!!!!!\n"
|
79
79
|
```
|
data/README.md.docu
CHANGED
@@ -39,7 +39,7 @@ MarkdownExpander::Expander.new(
|
|
39
39
|
"# Title: {{thing.title}}"
|
40
40
|
).render(
|
41
41
|
thing: {title: "Hello"}
|
42
|
-
)
|
42
|
+
)
|
43
43
|
#=> "# Title: Hello"
|
44
44
|
:end:
|
45
45
|
```
|
@@ -58,7 +58,7 @@ TEMPLATE
|
|
58
58
|
|
59
59
|
MarkdownExpander::Expander.new(template).render(
|
60
60
|
stuff: [ {title: "First!"}, {title: "Second!"} ]
|
61
|
-
)
|
61
|
+
)
|
62
62
|
#=> "# First!\n# Second!\n"
|
63
63
|
:end:
|
64
64
|
```
|
@@ -79,7 +79,7 @@ TEMPLATE
|
|
79
79
|
|
80
80
|
MarkdownExpander::Expander.new(template).render(
|
81
81
|
animals: [ {name: "dogs"}, {name: "cats"} ]
|
82
|
-
)
|
82
|
+
)
|
83
83
|
#=> "# cats are the best!!!!!\n"
|
84
84
|
:end:
|
85
85
|
```
|
data/lib/markdown-expander.rb
CHANGED
@@ -41,25 +41,38 @@ module MarkdownExpander
|
|
41
41
|
end
|
42
42
|
end
|
43
43
|
end
|
44
|
+
current_line += 1
|
44
45
|
end
|
45
46
|
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
47
|
+
parse_error = if node != root
|
48
|
+
if node.element.class == IfStart
|
49
|
+
MarkdownExpandError.new(node.line_number, "if statement has no end")
|
50
|
+
elsif node.element.class == LoopStart
|
51
|
+
MarkdownExpandError.new(node.line_number, "loop has no end")
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
if parse_error.nil? == false
|
56
|
+
raise parse_error
|
53
57
|
end
|
54
58
|
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
59
|
+
begin
|
60
|
+
evaluate_nodes(root, scope)
|
61
|
+
rescue ExpressionDrillDownError => e
|
62
|
+
raise MarkdownExpandError.new(
|
63
|
+
e.node.line_number,
|
64
|
+
"expression '#{e.expression}' could not be evaluated",
|
65
|
+
)
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
class MarkdownExpandError < StandardError
|
70
|
+
attr_reader :line_number
|
71
|
+
attr_reader :message
|
72
|
+
|
73
|
+
def initialize line_number, message
|
74
|
+
@line_number = line_number
|
75
|
+
@message = message
|
63
76
|
end
|
64
77
|
end
|
65
78
|
|
@@ -110,15 +123,6 @@ module MarkdownExpander
|
|
110
123
|
lines.join("")
|
111
124
|
end
|
112
125
|
|
113
|
-
class RenderResult
|
114
|
-
attr_reader :body
|
115
|
-
attr_reader :errors
|
116
|
-
def initialize body, errors
|
117
|
-
@body = body
|
118
|
-
@errors = errors
|
119
|
-
end
|
120
|
-
end
|
121
|
-
|
122
126
|
class Node
|
123
127
|
attr_accessor :parent
|
124
128
|
attr_accessor :children
|
data/lib/version.rb
CHANGED