Sha256: 0d1133ccf6b5f8410e15f41ce7e453d8214bd15a842987f07d3b632565e9d616

Contents?: true

Size: 1.11 KB

Versions: 103

Compression:

Stored size: 1.11 KB

Contents

require 'tilt'

module Temple
  module Templates
    class Tilt < ::Tilt::Template
      extend Mixins::Template

      define_options mime_type: 'text/html'

      def self.default_mime_type
        options[:mime_type]
      end

      def self.default_mime_type=(mime_type)
        options[:mime_type] = mime_type
      end

      # Prepare Temple template
      #
      # Called immediately after template data is loaded.
      #
      # @return [void]
      def prepare
        opts = {}.update(self.class.options).update(options).update(file: eval_file)
        opts.delete(:mime_type)
        if opts.include?(:outvar)
          opts[:buffer] = opts.delete(:outvar)
          opts[:save_buffer] = true
        end
        @src = self.class.compile(data, opts)
      end

      # A string containing the (Ruby) source code for the template.
      #
      # @param [Hash]   locals Local variables
      # @return [String] Compiled template ruby code
      def precompiled_template(locals = {})
        @src
      end

      def self.register_as(*names)
        ::Tilt.register(self, *names.map(&:to_s))
      end
    end
  end
end

Version data entries

103 entries across 89 versions & 7 rubygems

Version Path
cm-admin-1.5.22 vendor/bundle/ruby/3.3.0/gems/temple-0.8.2/lib/temple/templates/tilt.rb
cm-admin-1.5.21 vendor/bundle/ruby/3.3.0/gems/temple-0.8.2/lib/temple/templates/tilt.rb
cm-admin-1.5.20 vendor/bundle/ruby/3.3.0/gems/temple-0.8.2/lib/temple/templates/tilt.rb
brakeman-6.1.2 bundle/ruby/3.3.0/gems/temple-0.8.2/lib/temple/templates/tilt.rb
brakeman-6.1.1 bundle/ruby/3.0.0/gems/temple-0.8.2/lib/temple/templates/tilt.rb
brakeman-6.1.0 bundle/ruby/3.1.0/gems/temple-0.8.2/lib/temple/templates/tilt.rb
scrapbook-0.3.2 vendor/ruby/2.7.0/gems/temple-0.8.2/lib/temple/templates/tilt.rb
brakeman-6.0.1 bundle/ruby/3.1.0/gems/temple-0.8.2/lib/temple/templates/tilt.rb
scrapbook-0.3.1 vendor/ruby/2.7.0/gems/temple-0.8.2/lib/temple/templates/tilt.rb
brakeman-6.0.0 bundle/ruby/3.0.0/gems/temple-0.8.2/lib/temple/templates/tilt.rb
brakeman-5.4.1 bundle/ruby/3.1.0/gems/temple-0.8.2/lib/temple/templates/tilt.rb
brakeman-5.4.0 bundle/ruby/2.7.0/gems/temple-0.8.2/lib/temple/templates/tilt.rb
brakeman-5.3.1 bundle/ruby/2.7.0/gems/temple-0.8.2/lib/temple/templates/tilt.rb
brakeman-5.3.0 bundle/ruby/2.7.0/gems/temple-0.8.2/lib/temple/templates/tilt.rb
brakeman-5.2.3 bundle/ruby/2.7.0/gems/temple-0.8.2/lib/temple/templates/tilt.rb
brakeman-5.2.2 bundle/ruby/2.7.0/gems/temple-0.8.2/lib/temple/templates/tilt.rb
brakeman-5.2.1 bundle/ruby/2.7.0/gems/temple-0.8.2/lib/temple/templates/tilt.rb
brakeman-5.2.0 bundle/ruby/2.7.0/gems/temple-0.8.2/lib/temple/templates/tilt.rb
brakeman-5.1.2 bundle/ruby/2.7.0/gems/temple-0.8.2/lib/temple/templates/tilt.rb
brakeman-5.1.1 bundle/ruby/2.7.0/gems/temple-0.8.2/lib/temple/templates/tilt.rb