opulent 1.3.0 → 1.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/opulent/engine.rb +15 -36
- data/lib/opulent/template.rb +1 -1
- 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: 596ef0227f053f8528322c84b30f62f9cda06106
|
4
|
+
data.tar.gz: c8f7380d83175b6eccc89ea6c7145ec99fe0db6a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 664437050fa5a2d6e802ba6858a8c3056a8d8e69add2dd1187858d61c80a97ed06f6a291c0bf0e06665a3d5d033fa411a889a9920fc5736f4d3a55a7f9a9e32e
|
7
|
+
data.tar.gz: 0c74ec3b919fdca5cca863c9fd99b59442a94938f139d6183d848106ebc37e3d2723ce7de063152d8deab8fabcbd61f88fb4f6563e4b254199737f18c28226f6
|
data/lib/opulent/engine.rb
CHANGED
@@ -26,19 +26,6 @@ module Opulent
|
|
26
26
|
Settings.update_settings settings unless settings.empty?
|
27
27
|
end
|
28
28
|
|
29
|
-
# Analyze the input code and check for matching tokens. In case no match was
|
30
|
-
# found, throw an exception. In special cases, modify the token hash.
|
31
|
-
#
|
32
|
-
# @param file [String] The file that needs to be analyzed
|
33
|
-
# @param locals [Hash] Render call local variables
|
34
|
-
# @param block [Proc] Processing environment data
|
35
|
-
#
|
36
|
-
def render_file(file, locals = {}, &block)
|
37
|
-
@mode = :file
|
38
|
-
|
39
|
-
render file, locals, &block
|
40
|
-
end
|
41
|
-
|
42
29
|
# Avoid code duplication when layouting is set. When we have a layout, look
|
43
30
|
# in layouts/application by default.
|
44
31
|
#
|
@@ -52,11 +39,11 @@ module Opulent
|
|
52
39
|
if Settings[:layouts]
|
53
40
|
layout = locals.has_key?(:layout) ? locals.delete(:layout) : Settings[:default_layout]
|
54
41
|
|
55
|
-
|
56
|
-
|
42
|
+
process layout, locals, block do
|
43
|
+
process input, locals, block
|
57
44
|
end
|
58
45
|
else
|
59
|
-
|
46
|
+
process input, locals, block
|
60
47
|
end
|
61
48
|
end
|
62
49
|
|
@@ -67,9 +54,18 @@ module Opulent
|
|
67
54
|
# @param locals [Hash] Render call local variables
|
68
55
|
# @param block [Proc] Processing environment data
|
69
56
|
#
|
70
|
-
def
|
71
|
-
#
|
72
|
-
|
57
|
+
def process(input, locals, block, &content)
|
58
|
+
# Read input parameter based on opening mode. If we have a file mode, we
|
59
|
+
# get its path and read the code. We need to reset the mode in case the next
|
60
|
+
# render call is on code, not on a file.
|
61
|
+
@code = case input
|
62
|
+
when Symbol
|
63
|
+
@file = File.expand_path "#{input}.op"
|
64
|
+
File.read @file
|
65
|
+
else
|
66
|
+
@file = File.expand_path __FILE__
|
67
|
+
input
|
68
|
+
end
|
73
69
|
|
74
70
|
# Get the nodes tree
|
75
71
|
@nodes, @definitions = Parser.new(@file, @definitions).parse @code
|
@@ -94,22 +90,5 @@ module Opulent
|
|
94
90
|
|
95
91
|
return @output
|
96
92
|
end
|
97
|
-
|
98
|
-
# Read input parameter based on opening mode. If we have a file mode, we
|
99
|
-
# get its path and read the code. We need to reset the mode in case the next
|
100
|
-
# render call is on code, not on a file.
|
101
|
-
#
|
102
|
-
# @param input [String] Input file or code
|
103
|
-
#
|
104
|
-
def read(input)
|
105
|
-
if @mode == :file
|
106
|
-
@file = File.expand_path "#{input}.op"
|
107
|
-
@mode = nil unless Settings[:layouts]
|
108
|
-
return File.read @file
|
109
|
-
else
|
110
|
-
@file = File.expand_path __FILE__
|
111
|
-
return input
|
112
|
-
end
|
113
|
-
end
|
114
93
|
end
|
115
94
|
end
|
data/lib/opulent/template.rb
CHANGED
data/lib/opulent/version.rb
CHANGED