Sha256: 2e78b800e5388cb0425186b815bf9e602d2617b7618ad360322cedfbd6b9f3d3

Contents?: true

Size: 459 Bytes

Versions: 9

Compression:

Stored size: 459 Bytes

Contents

require 'mustache'

class Lambda < Mustache
  self.path = File.dirname(__FILE__)

  attr_reader :calls

  def initialize(*args)
    super
    @calls = 0
    @cached = nil
  end

  def rendered
    lambda do |text|
      return @cached if @cached

      @calls += 1
      @cached = render(text)
    end
  end

  def not_rendered
    lambda { |text| "{{= | =}}#{text}" }
  end
end

if $0 == __FILE__
  puts Lambda.to_html(Lambda.template, :name => "Jonny")
end

Version data entries

9 entries across 9 versions & 2 rubygems

Version Path
zine_brewer-1.5.0 vendor/bundle/ruby/2.7.0/gems/mustache-1.1.1/test/fixtures/lambda.rb
zine_brewer-1.3.0 vendor/bundle/ruby/2.7.0/gems/mustache-1.1.1/test/fixtures/lambda.rb
mustache-1.1.1 test/fixtures/lambda.rb
mustache-1.1.0 test/fixtures/lambda.rb
mustache-1.0.5 test/fixtures/lambda.rb
mustache-1.0.3 test/fixtures/lambda.rb
mustache-1.0.2 test/fixtures/lambda.rb
mustache-1.0.1 test/fixtures/lambda.rb
mustache-1.0.0 test/fixtures/lambda.rb