Sha256: 53f10469a682c0f46c8e57675922dea8f6cfc8489869f44881117961b90aae51

Contents?: true

Size: 976 Bytes

Versions: 199

Compression:

Stored size: 976 Bytes

Contents

require 'tilt/template'
require 'radius'

module Tilt
  # Radius Template
  # http://github.com/jlong/radius/
  class RadiusTemplate < Template
    def self.context_class
      @context_class ||= Class.new(Radius::Context) do
        attr_accessor :tilt_scope

        def tag_missing(name, attributes)
          tilt_scope.__send__(name)
        end

        def dup
          i = super
          i.tilt_scope = tilt_scope
          i
        end
      end
    end

    def prepare
    end

    def evaluate(scope, locals, &block)
      context = self.class.context_class.new
      context.tilt_scope = scope
      context.define_tag("yield") do
        block.call
      end
      locals.each do |tag, value|
        context.define_tag(tag) do
          value
        end
      end

      options = {:tag_prefix => 'r'}.merge(@options)
      parser = Radius::Parser.new(context, options)
      parser.parse(data)
    end

    def allows_script?
      false
    end
  end
end

Version data entries

199 entries across 160 versions & 28 rubygems

Version Path
cm-admin-1.5.22 vendor/bundle/ruby/3.3.0/gems/tilt-2.0.10/lib/tilt/radius.rb
cm-admin-1.5.21 vendor/bundle/ruby/3.3.0/gems/tilt-2.0.10/lib/tilt/radius.rb
cm-admin-1.5.20 vendor/bundle/ruby/3.3.0/gems/tilt-2.0.10/lib/tilt/radius.rb
brakeman-6.1.2 bundle/ruby/3.3.0/gems/tilt-2.0.11/lib/tilt/radius.rb
brakeman-6.1.1 bundle/ruby/3.0.0/gems/tilt-2.0.11/lib/tilt/radius.rb
brakeman-6.1.0 bundle/ruby/3.1.0/gems/tilt-2.0.11/lib/tilt/radius.rb
scrapbook-0.3.2 vendor/ruby/2.7.0/gems/tilt-2.0.10/lib/tilt/radius.rb
scrapbook-0.3.2 vendor/ruby/2.7.0/gems/tilt-2.0.11/lib/tilt/radius.rb
brakeman-6.0.1 bundle/ruby/3.1.0/gems/tilt-2.0.11/lib/tilt/radius.rb
scrapbook-0.3.1 vendor/ruby/2.7.0/gems/tilt-2.0.11/lib/tilt/radius.rb
scrapbook-0.3.1 vendor/ruby/2.7.0/gems/tilt-2.0.10/lib/tilt/radius.rb
rubypitaya-3.12.5 ./lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/tilt-2.0.11/lib/tilt/radius.rb
brakeman-6.0.0 bundle/ruby/3.0.0/gems/tilt-2.0.11/lib/tilt/radius.rb
brakeman-5.4.1 bundle/ruby/3.1.0/gems/tilt-2.0.11/lib/tilt/radius.rb
tilt-2.1.0 lib/tilt/radius.rb
rubypitaya-3.12.4 ./lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/tilt-2.0.11/lib/tilt/radius.rb
rubypitaya-3.12.3 ./lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/tilt-2.0.11/lib/tilt/radius.rb
rubypitaya-3.12.2 ./lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/tilt-2.0.11/lib/tilt/radius.rb
brakeman-5.4.0 bundle/ruby/2.7.0/gems/tilt-2.0.11/lib/tilt/radius.rb
brakeman-5.3.1 bundle/ruby/2.7.0/gems/tilt-2.0.11/lib/tilt/radius.rb