class Tilt::StaticTemplate
Static templates are templates that return the same output for every render
Instead of inheriting from the StaticTemplate
class, you will use the .subclass method with a block which processes @data and returns the transformed value.
Basic example which transforms the template to uppercase:
UppercaseTemplate = Tilt::StaticTemplate.subclass do @data.upcase end
Public Class Methods
Source
# File lib/tilt/template.rb 564 def self.subclass(mime_type: 'text/html', &block) 565 Class.new(self) do 566 self.default_mime_type = mime_type 567 568 private 569 570 define_method(:_prepare_output, &block) 571 end 572 end
Public Instance Methods
Source
# File lib/tilt/template.rb 586 def allows_script? 587 false 588 end
Static templates never allow script.
Source
# File lib/tilt/template.rb 581 def compiled_method(locals_keys, scope_class=nil) 582 raise NotImplementedError 583 end
Raise NotImplementedError, since static templates do not support compiled methods.
Source
# File lib/tilt/template.rb 575 def render(scope=nil, locals=nil) 576 @output 577 end
Static templates always return the prepared output.
Protected Instance Methods
Private Instance Methods
Source
# File lib/tilt/template.rb 599 def set_compiled_method_cache 600 end
Do nothing, since compiled method cache is not used.
Source
# File lib/tilt/template.rb 603 def set_fixed_locals 604 end
Do nothing, since fixed locals are not used.