opulent 1.5.5 → 1.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CODE_OF_CONDUCT.md +13 -0
- data/{LICENSE → LICENSE.md} +0 -0
- data/bin/opulent +0 -0
- data/lib/opulent.rb +10 -10
- data/lib/opulent/compiler.rb +15 -9
- data/lib/opulent/compiler/buffer.rb +123 -62
- data/lib/opulent/compiler/comment.rb +3 -4
- data/lib/opulent/compiler/control.rb +20 -26
- data/lib/opulent/compiler/define.rb +88 -36
- data/lib/opulent/compiler/doctype.rb +20 -22
- data/lib/opulent/compiler/eval.rb +23 -2
- data/lib/opulent/compiler/filter.rb +4 -5
- data/lib/opulent/compiler/node.rb +18 -12
- data/lib/opulent/compiler/root.rb +4 -5
- data/lib/opulent/compiler/text.rb +7 -2
- data/lib/opulent/compiler/yield.rb +2 -3
- data/lib/opulent/engine.rb +21 -20
- data/lib/opulent/exec.rb +21 -63
- data/lib/opulent/logger.rb +230 -3
- data/lib/opulent/parser.rb +14 -76
- data/lib/opulent/parser/comment.rb +45 -34
- data/lib/opulent/parser/control.rb +132 -111
- data/lib/opulent/parser/define.rb +15 -12
- data/lib/opulent/parser/doctype.rb +15 -15
- data/lib/opulent/parser/eval.rb +16 -6
- data/lib/opulent/parser/expression.rb +87 -84
- data/lib/opulent/parser/filter.rb +31 -25
- data/lib/opulent/parser/include.rb +38 -42
- data/lib/opulent/parser/node.rb +136 -118
- data/lib/opulent/parser/root.rb +24 -18
- data/lib/opulent/parser/text.rb +150 -123
- data/lib/opulent/parser/yield.rb +23 -23
- data/lib/opulent/settings.rb +70 -51
- data/lib/opulent/tokens.rb +17 -15
- data/lib/opulent/utils.rb +5 -4
- data/lib/opulent/version.rb +1 -1
- metadata +4 -43
- data/.libold/opulent.rb +0 -96
- data/.libold/opulent/context.rb +0 -80
- data/.libold/opulent/engine.rb +0 -88
- data/.libold/opulent/filter.rb +0 -101
- data/.libold/opulent/logger.rb +0 -67
- data/.libold/opulent/nodes.rb +0 -13
- data/.libold/opulent/nodes/block.rb +0 -29
- data/.libold/opulent/nodes/comment.rb +0 -35
- data/.libold/opulent/nodes/control.rb +0 -230
- data/.libold/opulent/nodes/define.rb +0 -42
- data/.libold/opulent/nodes/eval.rb +0 -41
- data/.libold/opulent/nodes/expression.rb +0 -28
- data/.libold/opulent/nodes/filter.rb +0 -70
- data/.libold/opulent/nodes/helper.rb +0 -69
- data/.libold/opulent/nodes/node.rb +0 -101
- data/.libold/opulent/nodes/root.rb +0 -62
- data/.libold/opulent/nodes/text.rb +0 -54
- data/.libold/opulent/nodes/theme.rb +0 -36
- data/.libold/opulent/parser.rb +0 -252
- data/.libold/opulent/parser/block.rb +0 -70
- data/.libold/opulent/parser/comment.rb +0 -32
- data/.libold/opulent/parser/control.rb +0 -83
- data/.libold/opulent/parser/define.rb +0 -39
- data/.libold/opulent/parser/eval.rb +0 -33
- data/.libold/opulent/parser/expression.rb +0 -350
- data/.libold/opulent/parser/filter.rb +0 -41
- data/.libold/opulent/parser/node.rb +0 -232
- data/.libold/opulent/parser/root.rb +0 -96
- data/.libold/opulent/parser/text.rb +0 -114
- data/.libold/opulent/parser/theme.rb +0 -36
- data/.libold/opulent/preprocessor.rb +0 -102
- data/.libold/opulent/runtime.rb +0 -144
- data/.libold/opulent/template.rb +0 -43
- data/.libold/opulent/tokens.rb +0 -276
- data/.libold/opulent/version.rb +0 -5
- data/.travis.yml +0 -4
- data/benchmark/benchmark.rb +0 -57
- data/benchmark/cases/node/node.haml +0 -7
- data/benchmark/cases/node/node.op +0 -7
- data/benchmark/cases/node/node.slim +0 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a007e8b48526ae61f9367fd98af3037f2846386f
|
4
|
+
data.tar.gz: 8fc75200d7244046c2db7ab85e68b39a2d10f1f3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 123f89a2cc962b954a92097d21cd8f8e162810751887f68eb5d0d223bb35e1060fcc6bf852915d903d6aab8994648a668e83861a85a7d072aaa4a39f59e13a0b
|
7
|
+
data.tar.gz: 6be28781cabf242dd16ee1278e77564adf6770ab33c03f6e25a6a6adf02d51e48e50337f0b4b9316af0973159c5d59a06748d5cc49e5bb5945b3a66e0db63d99
|
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
# Contributor Code of Conduct
|
2
|
+
|
3
|
+
As contributors and maintainers of this project, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities.
|
4
|
+
|
5
|
+
We are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, age, or religion.
|
6
|
+
|
7
|
+
Examples of unacceptable behavior by participants include the use of sexual language or imagery, derogatory comments or personal attacks, trolling, public or private harassment, insults, or other unprofessional conduct.
|
8
|
+
|
9
|
+
Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct. Project maintainers who do not follow the Code of Conduct may be removed from the project team.
|
10
|
+
|
11
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by opening an issue or contacting one or more of the project maintainers.
|
12
|
+
|
13
|
+
This Code of Conduct is adapted from the [Contributor Covenant](http:contributor-covenant.org), version 1.0.0, available at [http://contributor-covenant.org/version/1/0/0/](http://contributor-covenant.org/version/1/0/0/)
|
data/{LICENSE → LICENSE.md}
RENAMED
File without changes
|
data/bin/opulent
CHANGED
File without changes
|
data/lib/opulent.rb
CHANGED
@@ -1,11 +1,11 @@
|
|
1
1
|
require 'tilt'
|
2
|
-
require_relative 'opulent/compiler
|
3
|
-
require_relative 'opulent/context
|
4
|
-
require_relative 'opulent/engine
|
5
|
-
require_relative 'opulent/
|
6
|
-
require_relative 'opulent/
|
7
|
-
require_relative 'opulent/
|
8
|
-
require_relative 'opulent/
|
9
|
-
require_relative 'opulent/
|
10
|
-
require_relative 'opulent/
|
11
|
-
require_relative 'opulent/
|
2
|
+
require_relative './opulent/compiler'
|
3
|
+
require_relative './opulent/context'
|
4
|
+
require_relative './opulent/engine'
|
5
|
+
require_relative './opulent/logger'
|
6
|
+
require_relative './opulent/parser'
|
7
|
+
require_relative './opulent/settings'
|
8
|
+
require_relative './opulent/template'
|
9
|
+
require_relative './opulent/tokens'
|
10
|
+
require_relative './opulent/utils'
|
11
|
+
require_relative './opulent/version'
|
data/lib/opulent/compiler.rb
CHANGED
@@ -26,7 +26,7 @@ module Opulent
|
|
26
26
|
#
|
27
27
|
# @param path [String] Current file path needed for include nodes
|
28
28
|
#
|
29
|
-
def initialize
|
29
|
+
def initialize(settings = {})
|
30
30
|
# Setup convention accessors
|
31
31
|
@type = 0
|
32
32
|
@value = 1
|
@@ -34,9 +34,12 @@ module Opulent
|
|
34
34
|
@children = 3
|
35
35
|
@indent = 4
|
36
36
|
|
37
|
+
# Inherit settings from Engine
|
38
|
+
@settings = settings
|
39
|
+
|
37
40
|
# Get special node types from the settings
|
38
|
-
@multi_node = Settings::
|
39
|
-
@inline_node = Settings::
|
41
|
+
@multi_node = Settings::MULTI_NODE
|
42
|
+
@inline_node = Settings::INLINE_NODE
|
40
43
|
|
41
44
|
# Initialize amble object
|
42
45
|
@template = [[:preamble]]
|
@@ -63,19 +66,24 @@ module Opulent
|
|
63
66
|
# Compile input nodes, replace them with their definitions and
|
64
67
|
#
|
65
68
|
# @param root_node [Array] Root node containing all document nodes
|
66
|
-
# @param context [Context] Context holding environment variables
|
67
69
|
#
|
68
|
-
def compile(root_node,
|
70
|
+
def compile(root_node, definitions = {})
|
69
71
|
# Compiler generated code
|
70
72
|
@code = ''
|
71
73
|
@generator = ''
|
74
|
+
@definitions = definitions
|
72
75
|
|
73
76
|
# Set initial parent, from which we start generating code
|
74
77
|
@sibling_stack << root_node[@children].size
|
75
78
|
|
79
|
+
# Write all node definitions as method defs
|
80
|
+
@definitions.each do |_, node|
|
81
|
+
define node
|
82
|
+
end
|
83
|
+
|
76
84
|
# Start building up the code from the root node
|
77
85
|
root_node[@children].each do |child|
|
78
|
-
root child, 0
|
86
|
+
root child, 0
|
79
87
|
end
|
80
88
|
|
81
89
|
@template << [:postamble]
|
@@ -96,9 +104,7 @@ module Opulent
|
|
96
104
|
#
|
97
105
|
def indent_lines(text, indent)
|
98
106
|
text ||= ''
|
99
|
-
text.lines.
|
100
|
-
result += indent + line
|
101
|
-
end
|
107
|
+
text.lines.map { |line| indent + line }.join
|
102
108
|
end
|
103
109
|
|
104
110
|
# Give an explicit error report where an unexpected sequence of tokens
|
@@ -1,5 +1,6 @@
|
|
1
1
|
# @Opulent
|
2
2
|
module Opulent
|
3
|
+
# @Compiler
|
3
4
|
class Compiler
|
4
5
|
# Output an object stream into the template
|
5
6
|
#
|
@@ -37,7 +38,8 @@ module Opulent
|
|
37
38
|
@template << [:eval, string]
|
38
39
|
end
|
39
40
|
|
40
|
-
# Set a local variable through buffer eval an object stream into
|
41
|
+
# Set a local variable through buffer eval an object stream into
|
42
|
+
# the template
|
41
43
|
#
|
42
44
|
# @param name [String] Variable identifier to be set
|
43
45
|
# @param name [String] Variable value to be set
|
@@ -54,7 +56,7 @@ module Opulent
|
|
54
56
|
# @param n [Fixnum] Number of characters to be removed
|
55
57
|
#
|
56
58
|
def buffer_remove_last_character(type = :freeze, n = 1)
|
57
|
-
@template[-1][1] = @template[-1][1][0..-1-n] if @template[-1][0] == type
|
59
|
+
@template[-1][1] = @template[-1][1][0..-1 - n] if @template[-1][0] == type
|
58
60
|
end
|
59
61
|
|
60
62
|
# Turn call node attributes into a hash string
|
@@ -62,15 +64,17 @@ module Opulent
|
|
62
64
|
# @param attributes [Array] Array of node attributes
|
63
65
|
#
|
64
66
|
def buffer_attributes_to_hash(attributes)
|
65
|
-
|
66
|
-
extend_map << (
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
67
|
+
'{' + attributes.inject([]) do |extend_map, (key, attribute)|
|
68
|
+
extend_map << (
|
69
|
+
":\"#{key}\" => " + if key == :class
|
70
|
+
'[' + attribute.map do |exp|
|
71
|
+
exp[@value]
|
72
|
+
end.join(', ') + ']'
|
73
|
+
else
|
74
|
+
attribute[@value]
|
75
|
+
end
|
76
|
+
)
|
77
|
+
end.join(', ') + '}'
|
74
78
|
end
|
75
79
|
|
76
80
|
# Go through the node attributes and apply extension where needed
|
@@ -81,30 +85,51 @@ module Opulent
|
|
81
85
|
def buffer_attributes(attributes, extension)
|
82
86
|
# Proc for setting class attribute extension, used as DRY closure
|
83
87
|
#
|
84
|
-
buffer_class_attribute_type_check =
|
88
|
+
buffer_class_attribute_type_check = proc do |variable, escape = true|
|
85
89
|
class_variable = buffer_set_variable :local, variable
|
90
|
+
|
86
91
|
buffer_eval "if #{class_variable}.is_a? Array"
|
87
|
-
escape
|
92
|
+
if escape
|
93
|
+
buffer_escape("#{class_variable}.join ' '")
|
94
|
+
else
|
95
|
+
buffer("#{class_variable}.join ' '")
|
96
|
+
end
|
97
|
+
|
88
98
|
buffer_eval "elsif #{class_variable}.is_a? Hash"
|
89
|
-
escape
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
99
|
+
if escape
|
100
|
+
buffer_escape("#{class_variable}.to_a.join ' '")
|
101
|
+
else
|
102
|
+
buffer("#{class_variable}.to_a.join ' '")
|
103
|
+
end
|
104
|
+
|
105
|
+
buffer_eval 'elsif [TrueClass, NilClass, FalseClass].include? ' \
|
106
|
+
"#{class_variable}.class"
|
107
|
+
|
108
|
+
buffer_eval 'else'
|
109
|
+
if escape
|
110
|
+
buffer_escape("#{class_variable}")
|
111
|
+
else
|
112
|
+
buffer("#{class_variable}")
|
113
|
+
end
|
114
|
+
|
115
|
+
buffer_eval 'end'
|
94
116
|
end
|
95
117
|
|
96
118
|
# Handle class attributes by checking if they're simple, noninterpolated
|
97
119
|
# strings and extend them if needed
|
98
120
|
#
|
99
|
-
buffer_class_attribute =
|
100
|
-
if attribute[@value] =~ Tokens[:
|
101
|
-
buffer_split_by_interpolation attribute[@value][1..-2]
|
121
|
+
buffer_class_attribute = proc do |attribute|
|
122
|
+
if attribute[@value] =~ Tokens[:exp_string_match]
|
123
|
+
buffer_split_by_interpolation attribute[@value][1..-2],
|
124
|
+
attribute[@options][:escaped]
|
102
125
|
else
|
103
|
-
buffer_class_attribute_type_check[
|
126
|
+
buffer_class_attribute_type_check[
|
127
|
+
attribute[@value],
|
128
|
+
attribute[@options][:escaped]
|
129
|
+
]
|
104
130
|
end
|
105
131
|
end
|
106
132
|
|
107
|
-
|
108
133
|
# If we have class attributes, process each one and check if we have an
|
109
134
|
# extension for them
|
110
135
|
if attributes[:class]
|
@@ -113,7 +138,7 @@ module Opulent
|
|
113
138
|
# Process every class attribute
|
114
139
|
attributes[:class].each do |node_class|
|
115
140
|
buffer_class_attribute[node_class]
|
116
|
-
buffer_freeze
|
141
|
+
buffer_freeze ' '
|
117
142
|
end
|
118
143
|
|
119
144
|
# Remove trailing whitespace from the buffer
|
@@ -121,41 +146,51 @@ module Opulent
|
|
121
146
|
|
122
147
|
# Check for extension with :class key
|
123
148
|
if extension
|
124
|
-
buffer_eval "if #{extension}.has_key? :class"
|
125
|
-
buffer_freeze
|
126
|
-
buffer_class_attribute_type_check[
|
127
|
-
|
149
|
+
buffer_eval "if #{extension[:name]}.has_key? :class"
|
150
|
+
buffer_freeze ' '
|
151
|
+
buffer_class_attribute_type_check[
|
152
|
+
"#{extension[:name]}.delete(:class)"
|
153
|
+
]
|
154
|
+
buffer_eval 'end'
|
128
155
|
end
|
129
156
|
|
130
157
|
buffer_freeze '"'
|
131
158
|
elsif extension
|
132
159
|
# If we do not have class attributes but we do have an extension, try to
|
133
160
|
# see if the extension contains a class attribute
|
134
|
-
buffer_eval "if #{extension}.has_key? :class"
|
161
|
+
buffer_eval "if #{extension[:name]}.has_key? :class"
|
135
162
|
buffer_freeze " class=\""
|
136
|
-
buffer_class_attribute_type_check["#{extension}.delete(:class)"]
|
163
|
+
buffer_class_attribute_type_check["#{extension[:name]}.delete(:class)"]
|
137
164
|
buffer_freeze '"'
|
138
|
-
buffer_eval
|
165
|
+
buffer_eval 'end'
|
139
166
|
end
|
140
167
|
|
141
168
|
# Proc for setting class attribute extension, used as DRY closure
|
142
169
|
#
|
143
|
-
buffer_data_attribute_type_check =
|
170
|
+
buffer_data_attribute_type_check = proc do |key, variable, escape = true, dynamic = false|
|
144
171
|
# @Array
|
145
172
|
buffer_eval "if #{variable}.is_a? Array"
|
146
173
|
dynamic ? buffer("\" #{key}=\\\"\"") : buffer_freeze(" #{key}=\"")
|
147
|
-
|
174
|
+
|
175
|
+
if escape
|
176
|
+
buffer_escape("#{variable}.join '_'")
|
177
|
+
else
|
178
|
+
buffer("#{variable}.join '_'")
|
179
|
+
end
|
180
|
+
|
148
181
|
buffer_freeze '"'
|
149
182
|
|
150
183
|
# @Hash
|
151
184
|
buffer_eval "elsif #{variable}.is_a? Hash"
|
152
185
|
buffer_eval "#{variable}.each do |#{OPULENT_KEY}, #{OPULENT_VALUE}|"
|
153
|
-
|
186
|
+
# key-hashkey
|
187
|
+
dynamic ? buffer("\" #{key}-\"") : buffer_freeze(" #{key}-")
|
154
188
|
buffer "\"\#{#{OPULENT_KEY}}\""
|
189
|
+
#="value"
|
155
190
|
buffer_freeze "=\""
|
156
|
-
escape ? buffer_escape(
|
191
|
+
escape ? buffer_escape('_opulent_value') : buffer('_opulent_value')
|
157
192
|
buffer_freeze '"'
|
158
|
-
buffer_eval
|
193
|
+
buffer_eval 'end'
|
159
194
|
|
160
195
|
# @TrueClass
|
161
196
|
buffer_eval "elsif #{variable}.is_a? TrueClass"
|
@@ -165,44 +200,53 @@ module Opulent
|
|
165
200
|
buffer_eval "elsif [NilClass, FalseClass].include? #{variable}.class"
|
166
201
|
|
167
202
|
# @Object
|
168
|
-
buffer_eval
|
203
|
+
buffer_eval 'else'
|
169
204
|
dynamic ? buffer("\" #{key}=\\\"\"") : buffer_freeze(" #{key}=\"")
|
170
205
|
escape ? buffer_escape("#{variable}") : buffer("#{variable}")
|
171
206
|
buffer_freeze '"'
|
172
207
|
|
173
208
|
# End
|
174
|
-
buffer_eval
|
209
|
+
buffer_eval 'end'
|
175
210
|
end
|
176
211
|
|
177
212
|
# Handle data (normal) attributes by checking if they're simple, noninterpolated
|
178
213
|
# strings and extend them if needed
|
179
214
|
#
|
180
|
-
buffer_data_attribute =
|
215
|
+
buffer_data_attribute = proc do |key, attribute|
|
181
216
|
# When we have an extension for our attributes, check current key.
|
182
217
|
# If it exists, check it's type and generate everything dynamically
|
183
218
|
if extension
|
184
|
-
buffer_eval "if #{extension}.has_key? :\"#{key}\""
|
185
|
-
variable = buffer_set_variable :local,
|
186
|
-
|
187
|
-
|
219
|
+
buffer_eval "if #{extension[:name]}.has_key? :\"#{key}\""
|
220
|
+
variable = buffer_set_variable :local,
|
221
|
+
"#{extension[:name]}" \
|
222
|
+
".delete(:\"#{key}\")"
|
223
|
+
buffer_data_attribute_type_check[
|
224
|
+
key,
|
225
|
+
variable,
|
226
|
+
attribute[@options][:escaped]
|
227
|
+
]
|
228
|
+
buffer_eval 'else'
|
188
229
|
end
|
189
230
|
|
190
231
|
# Check if the set attribute is a simple string. If it is, freeze it or
|
191
232
|
# escape it. Otherwise, evaluate and initialize the type check.
|
192
|
-
if attribute[@value] =~ Tokens[:
|
233
|
+
if attribute[@value] =~ Tokens[:exp_string_match]
|
193
234
|
buffer_freeze " #{key}=\""
|
194
|
-
buffer_split_by_interpolation attribute[@value][1..-2],
|
235
|
+
buffer_split_by_interpolation attribute[@value][1..-2],
|
236
|
+
attribute[@options][:escaped]
|
195
237
|
buffer_freeze "\""
|
196
238
|
else
|
197
239
|
# Evaluate and type check
|
198
240
|
variable = buffer_set_variable :local, attribute[@value]
|
199
|
-
buffer_data_attribute_type_check[
|
241
|
+
buffer_data_attribute_type_check[
|
242
|
+
key,
|
243
|
+
variable,
|
244
|
+
attribute[@options][:escaped]
|
245
|
+
]
|
200
246
|
end
|
201
247
|
|
202
248
|
# Extension end
|
203
|
-
if extension
|
204
|
-
buffer_eval "end"
|
205
|
-
end
|
249
|
+
buffer_eval 'end' if extension
|
206
250
|
end
|
207
251
|
|
208
252
|
# Process the remaining, non-class related attributes
|
@@ -212,19 +256,26 @@ module Opulent
|
|
212
256
|
end
|
213
257
|
|
214
258
|
# Process remaining extension keys if there are any
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
259
|
+
return unless extension
|
260
|
+
|
261
|
+
buffer_eval "#{extension[:name]}.each do " \
|
262
|
+
"|ext#{OPULENT_KEY}, ext#{OPULENT_VALUE}|"
|
263
|
+
|
264
|
+
buffer_data_attribute_type_check[
|
265
|
+
"\#{ext#{OPULENT_KEY}}",
|
266
|
+
"ext#{OPULENT_VALUE}",
|
267
|
+
extension[:escaped],
|
268
|
+
true
|
269
|
+
]
|
270
|
+
buffer_eval 'end'
|
220
271
|
end
|
221
272
|
|
222
273
|
# Transform buffer array into a reusable template
|
223
274
|
#
|
224
275
|
def templatize
|
225
|
-
separator = DEBUG ? "\n" :
|
226
|
-
@template.
|
227
|
-
|
276
|
+
separator = DEBUG ? "\n" : '; ' # Readablity during development
|
277
|
+
@template.map do |input|
|
278
|
+
case input[0]
|
228
279
|
when :preamble
|
229
280
|
"#{BUFFER} = []#{separator}"
|
230
281
|
when :buffer
|
@@ -238,7 +289,7 @@ module Opulent
|
|
238
289
|
when :postamble
|
239
290
|
"#{BUFFER}.join"
|
240
291
|
end
|
241
|
-
end
|
292
|
+
end.join
|
242
293
|
end
|
243
294
|
|
244
295
|
# Split a string by its interpolation, then check if it really needs to be
|
@@ -248,11 +299,21 @@ module Opulent
|
|
248
299
|
# @param escape [Boolean] Escape string
|
249
300
|
#
|
250
301
|
def buffer_split_by_interpolation(string, escape = true)
|
251
|
-
string.split
|
252
|
-
|
253
|
-
|
302
|
+
parts = string.split Utils::INTERPOLATION_PATTERN
|
303
|
+
parts.each do |input|
|
304
|
+
if input =~ Utils::INTERPOLATION_PATTERN
|
305
|
+
input = input[2..-2]
|
306
|
+
if escape
|
307
|
+
buffer_escape input
|
308
|
+
else
|
309
|
+
buffer input
|
310
|
+
end
|
254
311
|
else
|
255
|
-
escape
|
312
|
+
if escape && input =~ Utils::ESCAPE_HTML_PATTERN
|
313
|
+
buffer_escape(input.inspect)
|
314
|
+
else
|
315
|
+
buffer_freeze(input)
|
316
|
+
end
|
256
317
|
end
|
257
318
|
end
|
258
319
|
end
|
@@ -6,13 +6,12 @@ module Opulent
|
|
6
6
|
#
|
7
7
|
# @param node [Array] Node code generation data
|
8
8
|
# @param indent [Fixnum] Size of the indentation to be added
|
9
|
-
# @param context [Context] Processing environment data
|
10
9
|
#
|
11
|
-
def comment(node, indent
|
10
|
+
def comment(node, indent)
|
12
11
|
buffer_freeze "\n" if node[@options][:newline]
|
13
|
-
buffer_freeze
|
12
|
+
buffer_freeze '<!-- '
|
14
13
|
buffer_split_by_interpolation node[@value].strip, false
|
15
|
-
buffer_freeze
|
14
|
+
buffer_freeze ' -->'
|
16
15
|
end
|
17
16
|
end
|
18
17
|
end
|