inversion 0.17.1 → 0.17.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 43b08253199cda04327e19141aefe596941482be
4
- data.tar.gz: 002f96158f9dbbe89ea1671c9d1abc827b80b55b
3
+ metadata.gz: 6745a33cc02610b46025e012922f4e510eb14825
4
+ data.tar.gz: 1fe0babb88461e808d34f82391aaf38b23328061
5
5
  SHA512:
6
- metadata.gz: b2c1e583e7d92c0e18f47f977fd0ffb3948af841d2446dd1029026f9b7ad593c0ca36a235235a0f30ad2e26ee7bddb8b197a5490cabb4b79ba71eebc9f06b934
7
- data.tar.gz: dd13d3317c1423bbd94c26bf2a031652981fa04536d98dad094354e10b6596428560246f2e24bb11e3e7e063d84412f405e37c37ac46018993d107f4aa0cd565
6
+ metadata.gz: 9412182ee80045940434ab81977cd1d879e42bd7d7e8c884e73aa0af154c67dcf384dca970dd91e8f492fc98be0b1f6d2153dc4ccd0afa20a7bb5f223e630e92
7
+ data.tar.gz: 3b3eeabfbe0a1a6eed93d13fe9db06af2c60d7a99bb55e216cbb6a039aca72579a86bce059d5746c583bcddbf821c51087553b5d7a6c5bd7813c2bc98a814c44
checksums.yaml.gz.sig CHANGED
Binary file
data.tar.gz.sig CHANGED
Binary file
data/History.rdoc CHANGED
@@ -1,3 +1,11 @@
1
+ == v0.17.2 [2015-01-22] Michael Granger <ged@FaerieMUD.org>
2
+
3
+ - Fix a bug with the fragment tag.
4
+
5
+ Fragments will now propagate to the container template when they're
6
+ added by inner templates.
7
+
8
+
1
9
  == v0.17.1 [2015-01-15] Michael Granger <ged@FaerieMUD.org>
2
10
 
3
11
  Re-push to fix a misbuilt gem.
data/lib/inversion.rb CHANGED
@@ -26,10 +26,10 @@ module Inversion
26
26
  warn ">>> Inversion requires Ruby 2.0.0 or later. <<<" if RUBY_VERSION < '2.0.0'
27
27
 
28
28
  # Library version constant
29
- VERSION = '0.17.1'
29
+ VERSION = '0.17.2'
30
30
 
31
31
  # Version-control revision constant
32
- REVISION = %q$Revision: 0d5760c23bc9 $
32
+ REVISION = %q$Revision: 25c7ea1fcb58 $
33
33
 
34
34
 
35
35
  ### Get the Inversion version.
@@ -344,6 +344,7 @@ class Inversion::RenderState
344
344
  ### Add one or more rendered +nodes+ to the state as a reusable fragment associated
345
345
  ### with the specified +name+.
346
346
  def add_fragment( name, *nodes )
347
+ self.log.debug "Adding a %s fragment with %d nodes." % [ name, nodes.size ]
347
348
  nodes.flatten!
348
349
  self.fragments[ name.to_sym ] = nodes
349
350
  self.scope.__fragments__[ name.to_sym ] = nodes
@@ -352,6 +353,7 @@ class Inversion::RenderState
352
353
 
353
354
  ### Return the current fragments Hash rendered as Strings.
354
355
  def rendered_fragments
356
+ self.log.debug "Rendering fragments: %p." % [ self.fragments.keys ]
355
357
  return self.fragments.each_with_object( {} ) do |(key, nodes), accum|
356
358
  accum[ key ] = self.stringify_nodes( nodes )
357
359
  end
@@ -338,7 +338,7 @@ class Inversion::Template
338
338
  ### Render the template, optionally passing a render state (if, for example, the
339
339
  ### template is being rendered inside another template).
340
340
  def render( parentstate=nil, &block )
341
- self.log.info "rendering template 0x%08x" % [ self.object_id/2 ]
341
+ self.log.info "rendering template %#x" % [ self.object_id/2 ]
342
342
  opts = self.options
343
343
  opts.merge!( parentstate.options ) if parentstate
344
344
 
@@ -348,10 +348,14 @@ class Inversion::Template
348
348
 
349
349
  # self.log.debug " rendering node tree: %p" % [ @node_tree ]
350
350
  self.walk_tree {|node| state << node }
351
- self.log.info " done rendering template 0x%08x: %0.4fs" %
351
+ self.log.info " done rendering template %#x: %0.4fs" %
352
352
  [ self.object_id/2, state.time_elapsed ]
353
353
 
354
- self.fragments.replace( state.rendered_fragments )
354
+ if parentstate
355
+ parentstate.fragments.merge!( state.fragments )
356
+ else
357
+ self.fragments.replace( state.rendered_fragments )
358
+ end
355
359
 
356
360
  return state.to_s
357
361
  end
@@ -45,11 +45,11 @@ class Inversion::Template::FragmentTag < Inversion::Template::Tag
45
45
  rendered_nodes = []
46
46
  renderstate.with_destination( rendered_nodes ) do
47
47
  sn = self.render_subnodes( renderstate )
48
- self.log.debug " subnodes are: %p" % [ sn ]
48
+ # self.log.debug " subnodes are: %p" % [ sn ]
49
49
  sn
50
50
  end
51
51
 
52
- self.log.debug " rendered nodes are: %p" % [ rendered_nodes ]
52
+ # self.log.debug " rendered nodes are: %p" % [ rendered_nodes ]
53
53
  renderstate.add_fragment( self.key, rendered_nodes )
54
54
 
55
55
  return nil
@@ -36,5 +36,22 @@ describe Inversion::Template::FragmentTag do
36
36
  expect( tmpl.fragments[:subject] ).to eq( "Order #2121bf8c4" )
37
37
  end
38
38
 
39
+
40
+ it "propagates fragments to the outermost template when they're nested" do
41
+ inner_tmpl = Inversion::Template.new(
42
+ '<?fragment subject ?>Order #<?attr order_number ?><?end?>-- <?attr subject ?> --'
43
+ )
44
+ outer_tmpl = Inversion::Template.new(
45
+ '<?attr content ?>'
46
+ )
47
+
48
+ inner_tmpl.order_number = '2121bf8c4'
49
+ outer_tmpl.content = inner_tmpl
50
+ output = outer_tmpl.render
51
+
52
+ expect( output ).to eq( "-- Order #2121bf8c4 --" )
53
+ expect( outer_tmpl.fragments[:subject] ).to eq( "Order #2121bf8c4" )
54
+ end
55
+
39
56
  end
40
57
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: inversion
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.17.1
4
+ version: 0.17.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Granger
@@ -31,7 +31,7 @@ cert_chain:
31
31
  c7ZKPJcWBv0sm81+FCZXNACn2f9jfF8OQinxVs0O052KbGuEQaaiGIYeuuwQE2q6
32
32
  ggcrPfcYeTwWlfZPu2LrBg==
33
33
  -----END CERTIFICATE-----
34
- date: 2015-01-16 00:00:00.000000000 Z
34
+ date: 2015-01-23 00:00:00.000000000 Z
35
35
  dependencies:
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: loggability
metadata.gz.sig CHANGED
@@ -1,2 +1,2 @@
1
- V�f�ʡ~ U��k�jɖS��~c͚�C�6�zP#9�my�H%ʆ��-�M��J���w�dXw���vh&���;i0���di��z��L8�]?tl�ofT�
2
- 0h.�t)yl�Bʬ3���6��D�&&�� 0���O%��ȥ�dL�)7������A�VA��/"�v���zAo��n[Θ�� WjEx�;"���B�`�̇�M��lq��/U�|��� xM���$�&����yr l�#��v�
1
+ �� �^(����\Q
2
+ !�ݚ w���$��L��lNZ��}Y:4�㻐5��6}^���ݎs��B:��ˑ��7tZ��2sb��[Ÿ��Xp�?ft&��6�=a�俓��M�puPa#"�d�a��GӘG�ꠔλ�.���{����Y0��OP_mYvb�zV��M}���p%�NwA������afڵK��������j�<`�E��\Sґc50AW��d%�V[@�:`v����A��jH����'�