Skip to content

Commit

Permalink
Extract MarkupTemplate into it's own file.
Browse files Browse the repository at this point in the history
  • Loading branch information
ioquatix committed Apr 27, 2024
1 parent 912fa6c commit 8879317
Showing 1 changed file with 0 additions and 31 deletions.
31 changes: 0 additions & 31 deletions lib/xrb/template.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 8879317

Please sign in to comment.