From 8879317d449befdba3a5c11f2dd109f89a4614a5 Mon Sep 17 00:00:00 2001 From: Samuel Williams Date: Sat, 27 Apr 2024 17:50:16 +1200 Subject: [PATCH] Extract `MarkupTemplate` into it's own file. --- lib/xrb/template.rb | 31 ------------------------------- 1 file changed, 31 deletions(-) diff --git a/lib/xrb/template.rb b/lib/xrb/template.rb index 60a9923..b92156b 100644 --- a/lib/xrb/template.rb +++ b/lib/xrb/template.rb @@ -130,35 +130,4 @@ def compile! assembler.code end end - - class MarkupTemplate < Template - class Assembler < Template::Assembler - # Output a string interpolation. - def expression(code) - @code << "#{OUT}<<(#{code});" - end - - # Output raw text to the template. - def text(text) - text = text.gsub("'", "\\\\'") - @code << "#{OUT}.raw('#{text}');" - end - end - - def to_string(scope = Object.new, output = nil) - super.output - end - - protected - - # We need an assembler which builds specific `Markup.append` sequences. - def make_assembler - Assembler.new - end - - # The output of the markup template is encoded markup (e.g. with entities, tags, etc). - def output_buffer - Builder.new(encoding: code.encoding) - end - end end