Sha256: f1dd3f955eda30a664742550b452e9083a680f603e80f43a8f221a3b1e63eeb0

Contents?: true

Size: 513 Bytes

Versions: 16

Compression:

Stored size: 513 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 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

16 entries across 16 versions & 3 rubygems

Version Path
mustache-0.99.8 test/fixtures/lambda.rb
mustache-0.99.7 test/fixtures/lambda.rb
mustache-0.99.6 test/fixtures/lambda.rb
mustache-0.99.5 test/fixtures/lambda.rb
resque-pool-0.3.0 vendor/bundle/ruby/1.8/gems/mustache-0.99.4/test/fixtures/lambda.rb
resque-pool-0.3.0.beta.2 vendor/bundle/ruby/1.8/gems/mustache-0.99.4/test/fixtures/lambda.rb
mustache-bibanon-0.99.5 test/fixtures/lambda.rb
mustache-0.99.4 test/fixtures/lambda.rb
mustache-0.99.3 test/fixtures/lambda.rb
mustache-0.99.2 test/fixtures/lambda.rb
mustache-0.99.1 test/fixtures/lambda.rb
mustache-0.99.0 test/fixtures/lambda.rb
mustache-0.98.0 test/fixtures/lambda.rb
mustache-0.13.0 test/fixtures/lambda.rb
mustache-0.12.1 test/fixtures/lambda.rb
mustache-0.12.0 test/fixtures/lambda.rb