Má tohle ekvivalent někde ve stardadních Railsech, případně pluginu?

Posted by Jan Kubr Sun, 23 Mar 2008 17:29:00 GMT
  def html_tag(name)
    "<#{name}>" + yield + "</#{name}>"
  end

  def div_tag
    html_tag('div') do
      yield
    end
  end

2 comments | Tags , | atom

Comments

Leave a response

  1. Avatar
    jana4u
    about 1 hour later:
    mozna content_tag(name, content_or_options_with_block = nil, options = nil, &block)
  2. Avatar
    jan
    about 5 hours later:
    Super! Diky, nemoh sem to najit. Takze pak asi takhle:
      def div_tag(content_or_options = nil, options_for_block_hater = nil, &block)
       if block_given? 
         content_tag('div', content_or_options) do
            yield
          end
       else
         content_tag('div', content_or_options, options_for_block_hater) 
       end
      end
    

    Nepredavat blok bych zakazal, rozhodne.

Leave a comment