Sha256: 73996ee8e624dbe442d99f972b3c3b3daf78e818b4def615f4dae57423a0356c

Contents?: true

Size: 1.76 KB

Versions: 4

Compression:

Stored size: 1.76 KB

Contents

module Zena::Use::Conditional
  module ZafuMethods

    def r_selenium
      return parser_error("missing 'id'.") if @name.blank?
      out expand_if("params[:test]==#{@name.inspect} || params[:test]=='all'")
    end

    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]
        if 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}} || @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

      if parent.method == 'case'
        with_context(:node => new_node) do
          r_elsif(cond)
        end
      else
        out expand_if(cond, new_node)
      end
    end
  end
end # Zena::Use::ZafuClass

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
zena-1.1.3 lib/zena/use/conditional.rb
zena-1.1.2 lib/zena/use/conditional.rb
zena-1.1.1 lib/zena/use/conditional.rb
zena-1.1.0 lib/zena/use/conditional.rb