Changeset 303
- Timestamp:
- 2007-02-23 00:25:03 (2 years ago)
- Files:
-
- trunk/lib/parser/lib/rules/zafu.rb (modified) (6 diffs)
- trunk/lib/parser/lib/rules/zena.rb (modified) (1 diff)
- trunk/lib/parser/test/parser_test.rb (modified) (1 diff)
- trunk/lib/parser/test/zafu.yml (modified) (1 diff)
- trunk/test/helpers/basic.yml (modified) (1 diff)
- trunk/test/helpers/test_all.rb (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/lib/parser/lib/rules/zafu.rb
r302 r303 12 12 @zafu_tag_done = false 13 13 res = super 14 if @zafu_tag&& !@zafu_tag_done14 if (@zafu_tag || @params[:tag]) && !@zafu_tag_done 15 15 if res =~ /\A\[(\w+)(.*)\/\]\Z/ 16 16 res = "[#{$1}#{$2}]<#{tag}/>[/#{$1}]" … … 32 32 33 33 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])}>" 36 36 @zafu_tag_done = true 37 37 res … … 72 72 @options.delete(:zafu_tag_params) 73 73 @zafu_tag_count = 1 74 elsif @zafu_tag = @options[:e at_zafu]75 @e at_zafu = true76 @options.delete(:e at_zafu)74 elsif @zafu_tag = @options[:end_zafu] 75 @end_zafu = true 76 @options.delete(:end_zafu) 77 77 @zafu_tag_count = 1 78 78 else 79 79 @zafu_tag_count = 0 80 80 end 81 @end_ztag = @options[:end_ztag] || @method 82 @options.delete(:end_ztag) 83 81 84 if @method == 'include' 82 85 include_template … … 85 88 86 89 # 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 88 95 89 96 all_params = @options[:do_params] … … 107 114 end 108 115 end 109 if @e at_zafu116 if @end_zafu 110 117 @zafu_tag = nil 111 118 end … … 157 164 # /ztag 158 165 eat $& 159 if $2 != @ method166 if $2 != @end_ztag 160 167 # error bad closing ztag 161 168 store "<span class='zafu_error'>#{$&.gsub('<', '<').gsub('>','>')}</span>" trunk/lib/parser/lib/rules/zena.rb
r302 r303 259 259 end 260 260 end 261 262 #if RAILS_ENV == 'test' 263 # def r_test 264 # inspect 265 # end 266 #end 261 267 262 268 def r_each trunk/lib/parser/test/parser_test.rb
r302 r303 22 22 testfile :zafu, :zafu_asset, :zafu_insight 23 23 def test_single 24 do_test('zafu', 'z afu_tag_closed')24 do_test('zafu', 'ztag_tag') 25 25 end 26 26 make_tests trunk/lib/parser/test/zafu.yml
r302 r303 188 188 res: "[test {= :param=>'1'}][test {= :param=>'2'}][hello {= :param=>'3'}/][/test][/test]" 189 189 190 do_multiple_with_zafu: 191 src: "" 192 res: "" 190 do_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 194 ztag_tag: 195 src: "<z:hello tag='p'/>" 196 res: "<p>hello world!</p>" trunk/test/helpers/basic.yml
r302 r303 294 294 295 295 do_each: 296 context: 297 node: 'wiki' 296 298 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>" 298 300 299 301 do_with_inner: 302 context: 303 node: 'wiki' 300 304 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 307 do_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 4 4 testfile :relations, :basic 5 5 def test_single 6 do_test('basic', 'do_each ')6 do_test('basic', 'do_each_do') 7 7 end 8 8 make_tests
