opulent 1.5.1 → 1.5.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/opulent/compiler.rb +1 -1
- data/lib/opulent/engine.rb +6 -1
- data/lib/opulent/exec.rb +2 -2
- data/lib/opulent/parser.rb +3 -2
- data/lib/opulent/template.rb +1 -1
- data/lib/opulent/tokens.rb +2 -2
- data/lib/opulent/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: e3de4d4452a9fce9f5c1d1917cea3d219e46315c
|
4
|
+
data.tar.gz: ed9f2ce680cdaa2307004f17f25576e10e3fc634
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7c0c0890404d3a84b89c8d04443d1c89630c6ac7b5d06761b094dadca117595e33c87e16e37e288aef91c2cc54212d329166fad64db13b037ca3c0e6c5217db3
|
7
|
+
data.tar.gz: 54fdd8b31913ceb54705f65e97c9bd9f513c80dd9405450f250bc44d6674e12857720311f2df76823eb489519bebb024895b2ceeeb33573981c6b773cde71ecb
|
data/lib/opulent/compiler.rb
CHANGED
data/lib/opulent/engine.rb
CHANGED
@@ -39,6 +39,10 @@ module Opulent
|
|
39
39
|
@template = Compiler.new.compile @nodes
|
40
40
|
end
|
41
41
|
|
42
|
+
# Read input as file or string input
|
43
|
+
#
|
44
|
+
# @param input [Object]
|
45
|
+
#
|
42
46
|
def read(input)
|
43
47
|
if input.is_a? Symbol
|
44
48
|
@file = File.expand_path get_eval_file input
|
@@ -79,8 +83,9 @@ module Opulent
|
|
79
83
|
scope.local_variable_set key, value
|
80
84
|
end
|
81
85
|
|
86
|
+
# Evaluate the template in the given scope (context)
|
82
87
|
begin
|
83
|
-
|
88
|
+
p "HELLO", @template
|
84
89
|
eval @template, scope
|
85
90
|
rescue ::SyntaxError => e
|
86
91
|
raise SyntaxError, e.message
|
data/lib/opulent/exec.rb
CHANGED
data/lib/opulent/parser.rb
CHANGED
@@ -64,7 +64,7 @@ module Opulent
|
|
64
64
|
# nodes and definitions
|
65
65
|
root @root
|
66
66
|
|
67
|
-
|
67
|
+
return @root, @definitions
|
68
68
|
end
|
69
69
|
|
70
70
|
# Check and accept or reject a given token as long as we have tokens
|
@@ -122,7 +122,7 @@ module Opulent
|
|
122
122
|
# @param token [RegEx] Token to be checked by the parser
|
123
123
|
#
|
124
124
|
def lookahead_next_line(token)
|
125
|
-
return unless @code[@i + 1]
|
125
|
+
return nil unless @code[@i + 1]
|
126
126
|
|
127
127
|
# Check if we match the token to the current line.
|
128
128
|
@code[@i + 1].match Tokens[token]
|
@@ -157,6 +157,7 @@ module Opulent
|
|
157
157
|
text.lines.inject('') do |_, line|
|
158
158
|
indent + line
|
159
159
|
end
|
160
|
+
text
|
160
161
|
end
|
161
162
|
|
162
163
|
# Give an explicit error report where an unexpected sequence of tokens
|
data/lib/opulent/template.rb
CHANGED
data/lib/opulent/tokens.rb
CHANGED
@@ -25,7 +25,7 @@ module Opulent
|
|
25
25
|
trailing_whitespace: /\A(\-\>)/,
|
26
26
|
|
27
27
|
# Self enclosing node
|
28
|
-
self_enclosing:
|
28
|
+
self_enclosing: /\A\/(.*)/,
|
29
29
|
|
30
30
|
# Definition
|
31
31
|
def: /\Adef +/,
|
@@ -50,7 +50,7 @@ module Opulent
|
|
50
50
|
inline_child: /\A *\> */,
|
51
51
|
|
52
52
|
# Comments
|
53
|
-
comment:
|
53
|
+
comment: /\A\//,
|
54
54
|
|
55
55
|
# Intepreted filters
|
56
56
|
filter: /\A\:[a-zA-Z]([\-\_]?[a-zA-Z0-9]+)*/,
|
data/lib/opulent/version.rb
CHANGED