clutterbuck-erb 0.2.1 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/lib/clutterbuck/erb.rb +16 -9
- metadata +2 -2
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA1:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: b20c25a1bf8be64d5dd7484415930552ccd2f8dd
         | 
| 4 | 
            +
              data.tar.gz: 0798a72beac26d61091fb32504afab652d5bafd1
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: 26ba437d264ca40a2ac4063d4ca8daac0c7f2a20e9d78134fb882c73058db061abb07b843a4f5a815c608d33347413c9c1fb090debd6e18b25db54061833482f
         | 
| 7 | 
            +
              data.tar.gz: ff15a21ab0e841003b0c34cef8611e9d3d802dd5d25884add61c85ba9c6eca213531f377cfe323187372720eb81e5024e80513fd7fd7a48e93aef0a78769bc40
         | 
    
        data/.gitignore
    CHANGED
    
    
    
        data/lib/clutterbuck/erb.rb
    CHANGED
    
    | @@ -30,9 +30,9 @@ module Clutterbuck::ERB | |
| 30 30 |  | 
| 31 31 | 
             
            		# Set or get the layout to use by default when rendering all templates.
         | 
| 32 32 | 
             
            		#
         | 
| 33 | 
            -
            		# @param l [Symbol] The layout  | 
| 33 | 
            +
            		# @param l [Symbol, Array<Symbol>] The layout specification to use.
         | 
| 34 34 | 
             
            		#
         | 
| 35 | 
            -
            		# @return Symbol
         | 
| 35 | 
            +
            		# @return [Symbol, Array<Symbol>]
         | 
| 36 36 | 
             
            		#
         | 
| 37 37 | 
             
            		def layout(l=Unspecified)
         | 
| 38 38 | 
             
            			if l != Unspecified
         | 
| @@ -107,12 +107,15 @@ module Clutterbuck::ERB | |
| 107 107 | 
             
            	#   Rack response.
         | 
| 108 108 | 
             
            	#
         | 
| 109 109 | 
             
            	def erb(view, vars)
         | 
| 110 | 
            -
            		 | 
| 110 | 
            +
            		render_chain = [@layout || self.class.layout, view].flatten.compact
         | 
| 111 111 |  | 
| 112 | 
            -
            		 | 
| 112 | 
            +
            		content = ""
         | 
| 113 113 |  | 
| 114 | 
            -
            		 | 
| 115 | 
            -
            			 | 
| 114 | 
            +
            		until render_chain.empty?
         | 
| 115 | 
            +
            			view = render_chain.pop
         | 
| 116 | 
            +
            			
         | 
| 117 | 
            +
            			cur_binding = get_binding(vars) { content.chomp }
         | 
| 118 | 
            +
            			content = erbterpreter(view).result(cur_binding)
         | 
| 116 119 | 
             
            		end
         | 
| 117 120 |  | 
| 118 121 | 
             
            		[
         | 
| @@ -128,7 +131,7 @@ module Clutterbuck::ERB | |
| 128 131 | 
             
            	# Specify a layout to use for this request.  Works identically to
         | 
| 129 132 | 
             
            	# {ClassMethods#layout} in all the relevant particulars.
         | 
| 130 133 | 
             
            	#
         | 
| 131 | 
            -
            	# @param l [Symbol]
         | 
| 134 | 
            +
            	# @param l [Symbol, Array<Symbol>]
         | 
| 132 135 | 
             
            	#
         | 
| 133 136 | 
             
            	def layout(l)
         | 
| 134 137 | 
             
            		@layout = l
         | 
| @@ -141,12 +144,16 @@ module Clutterbuck::ERB | |
| 141 144 | 
             
            	end
         | 
| 142 145 |  | 
| 143 146 | 
             
            	def view_content(view)
         | 
| 144 | 
            -
            		File.read( | 
| 147 | 
            +
            		File.read(view_file(view))
         | 
| 148 | 
            +
            	end
         | 
| 149 | 
            +
             | 
| 150 | 
            +
            	def view_file(view)
         | 
| 151 | 
            +
            		File.join(self.class.views, view.to_s + ".html.erb")
         | 
| 145 152 | 
             
            	end
         | 
| 146 153 |  | 
| 147 154 | 
             
            	def erbterpreter(view)
         | 
| 148 155 | 
             
            		file = view_content(view)
         | 
| 149 156 |  | 
| 150 | 
            -
            		ERB.new(file, 0, "%-").tap { |erb| erb.filename =  | 
| 157 | 
            +
            		ERB.new(file, 0, "%-").tap { |erb| erb.filename = view_file(view) }
         | 
| 151 158 | 
             
            	end
         | 
| 152 159 | 
             
            end
         | 
    
        metadata
    CHANGED
    
    | @@ -1,14 +1,14 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: clutterbuck-erb
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 0. | 
| 4 | 
            +
              version: 0.3.0
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - Matt Palmer
         | 
| 8 8 | 
             
            autorequire: 
         | 
| 9 9 | 
             
            bindir: bin
         | 
| 10 10 | 
             
            cert_chain: []
         | 
| 11 | 
            -
            date: 2015- | 
| 11 | 
            +
            date: 2015-07-08 00:00:00.000000000 Z
         | 
| 12 12 | 
             
            dependencies:
         | 
| 13 13 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 14 14 | 
             
              name: rack
         |