Skip to content

Commit

Permalink
Document use of StaticTemplate
Browse files Browse the repository at this point in the history
  • Loading branch information
adam12 committed Sep 5, 2024
1 parent 24e3c01 commit 69465bf
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions lib/tilt/template.rb
Original file line number Diff line number Diff line change
Expand Up @@ -413,6 +413,16 @@ def binary(string)
end
end

# 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
class StaticTemplate < Template
def self.subclass(mime_type: 'text/html', &block)
Class.new(self) do
Expand Down

0 comments on commit 69465bf

Please sign in to comment.