Sha256: 58bd570aee5a27de209998576c9c46796fc9c5bfb07b06ce5d33b584e52018d6

Contents?: true

Size: 444 Bytes

Versions: 3

Compression:

Stored size: 444 Bytes

Contents

$LOAD_PATH.unshift File.dirname(__FILE__) + '/../lib'
require 'mustache'

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

  attr_reader :calls

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

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

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

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

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
mustache-0.11.2 test/fixtures/lambda.rb
mustache-0.11.1 test/fixtures/lambda.rb
mustache-0.11.0 test/fixtures/lambda.rb