Sha256: 4d12d75620d540d89933ea8d07ec5a93f02bf995e51d78219e05594b233320c9

Contents?: true

Size: 756 Bytes

Versions: 3

Compression:

Stored size: 756 Bytes

Contents

module Tilt
  class Template
    # This patch allows to use of @keys as well as keys
    # Example:
    #   template.render({:@name => 'Piter'})
    def local_extraction(local_keys)
      local_keys.map do |k|
        if k.to_s =~ /\A@?[a-z_][a-zA-Z_0-9]*\z/ # this line patched
          "#{k} = locals[#{k.inspect}]"
        else
          raise "invalid locals key: #{k.inspect} (keys must be variable names)"
        end
      end.join("\n")
    end
  end
end

module TemplateInheritance
  class Template
    def template(options = {})
      options = {:escape_html => true, :raw_interpolated_tags => [:a, :link_to, :a_post, :img, :csrf_token, :csrf_token_tag]}.merge(options)
      @template ||= Tilt.new(self.fullpath, nil, options)
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
alfa-0.0.8.pre lib/tilt/alfa_patch.rb
alfa-0.0.7.pre lib/tilt/alfa_patch.rb
alfa-0.0.6.pre lib/tilt/alfa_patch.rb