Changeset 303

Show
Ignore:
Timestamp:
2007-02-23 00:25:03 (2 years ago)
Author:
gaspard
Message:

Zafu do syntax working fine with 'tag' parameter.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/lib/parser/lib/rules/zafu.rb

    r302 r303  
    1212      @zafu_tag_done = false 
    1313      res = super 
    14       if @zafu_tag && !@zafu_tag_done 
     14      if (@zafu_tag || @params[:tag]) && !@zafu_tag_done 
    1515        if res =~ /\A\[(\w+)(.*)\/\]\Z/ 
    1616          res = "[#{$1}#{$2}]<#{tag}/>[/#{$1}]" 
     
    3232     
    3333    def render_zafu_tag(text) 
    34       return text unless (@zafu_tag && !@zafu_tag_done) 
    35       res = "<#{@zafu_tag}#{params_to_html(@zafu_tag_params)}>#{text}</#{@zafu_tag}>" 
     34      return text unless ((@zafu_tag || @params[:tag]) && !@zafu_tag_done) 
     35      res = "<#{(@zafu_tag || @params[:tag])}#{params_to_html(@zafu_tag_params || {})}>#{text}</#{(@zafu_tag || @params[:tag])}>" 
    3636      @zafu_tag_done = true 
    3737      res 
     
    7272        @options.delete(:zafu_tag_params) 
    7373        @zafu_tag_count = 1 
    74       elsif @zafu_tag = @options[:eat_zafu] 
    75         @eat_zafu = true 
    76         @options.delete(:eat_zafu) 
     74      elsif @zafu_tag = @options[:end_zafu] 
     75        @end_zafu = true 
     76        @options.delete(:end_zafu) 
    7777        @zafu_tag_count = 1 
    7878      else 
    7979        @zafu_tag_count = 0 
    8080      end 
     81      @end_ztag = @options[:end_ztag] || @method 
     82      @options.delete(:end_ztag) 
     83       
    8184      if @method == 'include' 
    8285        include_template 
     
    8588         
    8689        # the matching zafu tag will be parsed by the last 'do', we must inform it to halt properly : 
    87         opts[:eat_zafu] = @zafu_tag if @zafu_tag 
     90        if @zafu_tag 
     91          opts[:end_zafu] = @zafu_tag 
     92        else 
     93          opts[:end_ztag] = @method 
     94        end 
    8895         
    8996        all_params = @options[:do_params] 
     
    107114        end 
    108115      end 
    109       if @eat_zafu 
     116      if @end_zafu 
    110117        @zafu_tag = nil 
    111118      end 
     
    157164          # /ztag 
    158165          eat $& 
    159           if $2 != @method 
     166          if $2 != @end_ztag 
    160167            # error bad closing ztag 
    161168            store "<span class='zafu_error'>#{$&.gsub('<', '&lt;').gsub('>','&gt;')}</span>" 
  • trunk/lib/parser/lib/rules/zena.rb

    r302 r303  
    259259      end 
    260260    end 
     261     
     262    #if RAILS_ENV == 'test' 
     263    #  def r_test 
     264    #    inspect 
     265    #  end 
     266    #end 
    261267  
    262268    def r_each 
  • trunk/lib/parser/test/parser_test.rb

    r302 r303  
    2222  testfile :zafu, :zafu_asset, :zafu_insight 
    2323  def test_single 
    24     do_test('zafu', 'zafu_tag_closed') 
     24    do_test('zafu', 'ztag_tag') 
    2525  end 
    2626  make_tests 
  • trunk/lib/parser/test/zafu.yml

    r302 r303  
    188188  res: "[test {= :param=>'1'}][test {= :param=>'2'}][hello {= :param=>'3'}/][/test][/test]" 
    189189 
    190 do_multiple_with_zafu: 
    191   src: "" 
    192   res: "" 
     190do_with_inner: 
     191  src: "<z:test do='hello'>a thing <z:hello/> here</z:test>" 
     192  res: "[test][hello]a thing [hello/] here[/hello][/test]" 
     193 
     194ztag_tag: 
     195  src: "<z:hello tag='p'/>" 
     196  res: "<p>hello world!</p>" 
  • trunk/test/helpers/basic.yml

    r302 r303  
    294294 
    295295do_each: 
     296  context: 
     297    node: 'wiki' 
    296298  src: "<z:children do='each'><z:link/></z:children>" 
    297   res: "
     299  res: "<a href=\"/oo/image20.html\">bird</a><a href=\"/oo/image21.html\">flower</a>
    298300 
    299301do_with_inner: 
     302  context: 
     303    node: 'wiki' 
    300304  src: "<ul zafu='children' do='each' tag='li'><z:show attr='name'/></ul>" 
    301   res: "<ul><li>...</li><li>...</li>" 
     305  res: "<ul><li>bird</li><li>flower</li></ul>" 
     306 
     307do_each_do: 
     308  context: 
     309    node: 'wiki' 
     310  src: "<ul zafu='children' do='each' tag='li' do='link'/>" 
     311  res: "<ul><li><a href=\"/oo/image20.html\">bird</a></li><li><a href=\"/oo/image21.html\">flower</a></li></ul>" 
  • trunk/test/helpers/test_all.rb

    r302 r303  
    44  testfile :relations, :basic 
    55  def test_single 
    6     do_test('basic', 'do_each') 
     6    do_test('basic', 'do_each_do') 
    77  end 
    88  make_tests