lib/masterview/directives/if.rb in masterview-0.2.5 vs lib/masterview/directives/if.rb in masterview-0.3.0
- old
+ new
@@ -1,23 +1,24 @@
module MasterView
module Directives
- #outputs an if/end block around the text tags
+ # outputs an if/end block around the text tags
+ #
class If < MasterView::DirectiveBase
- def priority
- DirectivePriorities::High
- end
- def stag(directive_call_stack)
- ret = []
- ret << erb('if '+attr_value)
- ret << directive_call_stack.render
+ metadata :priority => 'High',
+ :category => 'erb',
+ :description => 'Wraps the element with an if... end block using the attribute value for the condition'
+
+ #TODO: omit element entirely if attr_value == 'false'
+ #TODO: don't need to generate conditional block wrapping if attr_value == 'true'
+
+ event :before_stag do
+ render erb_eval( 'if', attr_value )
end
- def etag(directive_call_stack)
- ret = []
- ret << directive_call_stack.render
- ret << erb('end')
+ event :after_etag do
+ render erb_eval( 'end' )
end
end
end
end