Module: Zena::Use::Conditional::ZafuMethods
- Defined in:
- lib/zena/use/conditional.rb
Instance Method Summary collapse
Instance Method Details
#r_selenium ⇒ Object
4 5 6 7 |
# File 'lib/zena/use/conditional.rb', line 4 def r_selenium return parser_error("missing 'id'.") if @name.blank? out ("params[:test]==#{@name.inspect} || params[:test]=='all'") end |
#rubyless_class_scope(class_name) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/zena/use/conditional.rb', line 9 def rubyless_class_scope(class_name) return parser_error("Cannot scope class in list (use each before filtering).") if node.list_context? # capital letter ==> class conditional if klass = VirtualClass[class_name] # FIXME: This does not always work... (block inside block resets class scoping...). We should always render blocks with 'Node' class... #if node.klass.kpath =~ %r{^#{klass.kpath}} || klass.kpath =~ %r{^#{node.klass.kpath}} || @context[:saved_template] # Saved templates can be rendered with anything... # FIXME: Make sure saved templates from 'block' start with the proper node type ? cond = "#{node}.kpath_match?('#{klass.kpath}')" new_node = node.move_to(node.name, klass) #else # # render nothing: incompatible classes # cond = 'false' # new_node = node.move_to(node.name, klass) #end elsif role = Node.get_role(class_name) #if node.klass.kpath =~ %r{^#{role.kpath}} || role.kpath =~ %r{^#{node.klass.kpath}} || @context[:saved_template] # # Saved templates can be rendered with anything... # # FIXME: Make sure saved templates from 'block' start with the proper node type ? cond = "#{node}.has_role?(#{role.id})" new_node = node.move_to(node.name, node.klass) #else # # render nothing: incompatible classes # cond = 'false' # new_node = node.move_to(node.name, node.klass) #end else return parser_error("Invalid role or class '#{class_name}'") end # Class filtering should not block 'saved_dom_id' propagation. new_node.saved_dom_id = node.saved_dom_id if parent.method == 'case' with_context(:node => new_node) do r_elsif(cond) end else out (cond, new_node) end end |