lib/macros4cuke/templating/engine.rb in macros4cuke-0.5.07 vs lib/macros4cuke/templating/engine.rb in macros4cuke-0.5.08
- old
+ new
@@ -11,16 +11,13 @@
require_relative 'placeholder'
require_relative 'section' # Load the Section and ConditionalSection
module Macros4Cuke # Module used as a namespace
-
-
# Module containing all classes implementing the simple template engine
# used internally in Macros4Cuke.
module Templating
-
# A very simple implementation of a templating engine.
# Earlier versions of Macros4Cuke relied on the logic-less
# Mustache template engine.
# But it was decided afterwards to replace it by a very simple
# template engine.
@@ -75,11 +72,11 @@
result = @representation.each_with_object('') do |element, subResult|
# Output compaction rules:
# -In case of consecutive eol's only one is rendered.
# -In case of comment followed by one eol, both aren't rendered
unless element.is_a?(EOLine) &&
- (prev.is_a?(EOLine) || prev.is_a?(Comment))
+ (prev.is_a?(EOLine) || prev.is_a?(Comment))
subResult << element.render(aContextObject, theLocals)
end
prev = element
end
@@ -97,13 +94,10 @@
when Placeholder
subResult << element.name
when Section
subResult.concat(element.variables)
-
- else
- # Do nothing
end
end
vars.flatten.uniq
end
@@ -314,18 +308,14 @@
if sections.empty?
msg = 'found while no corresponding section is open.'
fail(StandardError, msg_prefix + msg)
end
- if marker.name != sections.last.name
- msg = "doesn't match current section '#{sections.last.name}'."
- fail(StandardError, msg_prefix + msg)
- end
+ return if marker.name == sections.last.name
+ msg = "doesn't match current section '#{sections.last.name}'."
+ fail(StandardError, msg_prefix + msg)
end
-
end # class
-
end # module
-
end # module
# End of file