lib/masterview/directives/block.rb in masterview-0.2.5 vs lib/masterview/directives/block.rb in masterview-0.3.0
- old
+ new
@@ -1,28 +1,25 @@
module MasterView
module Directives
- #outputs a block around the text tags, if left bracket count is higher than right
- #assume that the end is a right bracket otherwise use end
+ # outputs a block around the text tags, if left bracket count is higher than right
+ # assume that the end is a right bracket otherwise use end
+ #
class Block < MasterView::DirectiveBase
- def priority
- DirectivePriorities::MediumHigh
- end
- def stag(directive_call_stack)
+ metadata :priority => 'MediumHigh',
+ :category => 'erb',
+ :description => 'Expands to the equivalent rhtml (erb) block code around the element'
+
+ event :before_stag do
count_left_brackets = attr_value.scan( /\{/ ).size
count_right_brackets = attr_value.scan( /\}/ ).size
@end_block = (count_left_brackets > count_right_brackets) ? '}' : 'end'
-
- ret = []
- ret << erb(attr_value)
- ret << directive_call_stack.render
+ render erb_eval(attr_value)
end
- def etag(directive_call_stack)
- ret = []
- ret << directive_call_stack.render
- ret << erb(@end_block)
+ event :after_etag do
+ render erb_eval(@end_block)
end
end
end
end