Sha256: 9bde6350e3b3960231cd0b355f46f82580c8a8f889ea393acf5719c7f7a6a9c2

Contents?: true

Size: 1020 Bytes

Versions: 7

Compression:

Stored size: 1020 Bytes

Contents

# frozen_string_literal: true
require 'tilt'

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

      define_options mime_type: 'text/html'

      # 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)
        metadata[:mime_type] = 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

7 entries across 7 versions & 2 rubygems

Version Path
brakeman-6.2.2 bundle/ruby/3.1.0/gems/temple-0.10.3/lib/temple/templates/tilt.rb
brakeman-6.2.2.rc1 bundle/ruby/3.3.0/gems/temple-0.10.3/lib/temple/templates/tilt.rb
brakeman-6.2.1 bundle/ruby/3.1.0/gems/temple-0.10.3/lib/temple/templates/tilt.rb
brakeman-6.2.0 bundle/ruby/3.1.0/gems/temple-0.10.3/lib/temple/templates/tilt.rb
temple-0.10.3 lib/temple/templates/tilt.rb
temple-0.10.2 lib/temple/templates/tilt.rb
temple-0.10.1 lib/temple/templates/tilt.rb