From 69465bf9070db8738ed7ce28471fb3858dc004ae Mon Sep 17 00:00:00 2001 From: Adam Daniels Date: Thu, 5 Sep 2024 13:46:35 -0400 Subject: [PATCH] Document use of StaticTemplate --- lib/tilt/template.rb | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/lib/tilt/template.rb b/lib/tilt/template.rb index 2f54f91..3d7283c 100644 --- a/lib/tilt/template.rb +++ b/lib/tilt/template.rb @@ -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