lib/masterview/directive_helpers.rb in masterview-0.2.2 vs lib/masterview/directive_helpers.rb in masterview-0.2.3

- old
+ new

@@ -1,13 +1,30 @@ module MasterView + # Mixin services for directive implementation classes. + # + # Subclasses of MasterView::DirectiveBase inherit this mixin. + # module DirectiveHelpers + CRLF = "\r\n" - ERB_START = '<% ' - ERB_EVAL = '<%= ' - ERB_END = ' %>' + # start of ERB which is evaluated but does not contribute content to the document + ERB_EVAL_START = '<% ' + # end of ERB which is evaluated but does not contribute content to the document + ERB_EVAL_END = ' -%>' + + # start of ERB whose evaluation results in content in the document + ERB_CONTENT_START = '<%= ' + # end of ERB whose evaluation results in content in the document + ERB_CONTENT_END = ' %>' + + ####OBSOLETE: SWEEP AND REMOVE + ERB_START = ERB_EVAL_START #:nodoc: #WAS: '<% ' + ERB_EVAL = ERB_CONTENT_START #:nodoc: #WAS: '<%= ' + ERB_END = ERB_CONTENT_END #:nodoc: #WAS: ' %>' + #convenience constants defined to allow priority to directives #higher priority (lower value) will be executed first in chain module DirectivePriorities Highest = 0 UltraHigh = 0x3FFFFFFF/16 @@ -122,16 +139,13 @@ h end #parse into array of strings, containing the various arguments without evaling #looks for %q{}, %q[], hash, array, function call using (), values deliminated by commas, - #it does not handle embedded quotes yet def parse(str) - return [] if str.nil? || str.strip.empty? - s = str.strip - args = [] - s.scan( /(%q"[^"]*"|%q\{[^}]*\}|%q\[[^\]]*\]|\{?\s*\S+\s*=>[^{}]+\}?|\[[^\]]*\]|[\w\.@]+\s*\([^\)]*\)|'[^']*'|[^,]+)\s*,?\s*/ ).flatten + AttrStringParser.parse(str) end + #remove any strings that were prepended to the hashes, typically these are overridden by other values, so # we need to strip them off leaving only the hashes, returns a string with only hashes def remove_prepended_strings(full_string) return full_string if full_string.nil? || full_string.strip.empty?