Sha256: a12b46c408b97a026427c8aee0eee3fdcdfe6eaaee32f9097a21001ca0f4f57b

Contents?: true

Size: 745 Bytes

Versions: 11

Compression:

Stored size: 745 Bytes

Contents

# A base namespace for template libraries to register their templates. This
# file is not loaded by opal directly, so a templating library would need to
# require this file itself (e.g. opal-erb.rb requires it, so each erb template)
# doesn't need to do it itself.
#
#     # foo.erb
#     ERB.new('foo') do
#       # template body
#     end
#
#     # inside opal-erb.rb
#     class ERB
#       def initialize(name, &block)
#         @block = block
#         Template[name] = self
#       end
#
#       # standard method for templates
#       def render(ctx)
#         #...
#       end
#     end
#
module Template
  @_cache = {}
  def self.[](name)
    @_cache[name]
  end

  def self.[]=(name, instance)
    @_cache[name] = instance
  end  
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
opal-0.4.2 opal/opal-template.rb
opal-0.4.1 opal/opal-template.rb
opal-0.4.0 opal/opal-template.rb
opal-0.3.44 opal/opal-template.rb
opal-0.3.43 opal/opal-template.rb
opal-0.3.42 opal/opal/template.rb
opal-0.3.41 opal/opal/template.rb
opal-0.3.40 lib/assets/javascripts/opal/template.rb
opal-0.3.39 lib/assets/javascripts/opal/template.rb
opal-0.3.38 lib/assets/javascripts/opal/template.rb
opal-0.3.37 lib/assets/javascripts/opal/template.rb