Class: CodeRay::Encoders::HTML::Output::Template

Inherits:
String
  • Object
show all
Defined in:
lib/coderay/encoders/html/output.rb

Defined Under Namespace

Modules: Simple

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from String

#gunzip, #gunzip!, #gzip, #gzip!

Class Method Details

.wrap!(str, template, target) ⇒ Object



122
123
124
125
126
127
128
129
130
# File 'lib/coderay/encoders/html/output.rb', line 122

def self.wrap! str, template, target
	target = Regexp.new(Regexp.escape("<%#{target}%>"))
	if template =~ target
		str[0,0] = $`
		str << $'
	else
		raise "Template target <%%%p%%> not found" % target
	end
end

Instance Method Details

#apply(target, replacement) ⇒ Object



132
133
134
135
136
137
138
139
# File 'lib/coderay/encoders/html/output.rb', line 132

def apply target, replacement
	target = Regexp.new(Regexp.escape("<%#{target}%>"))
	if self =~ target
		Template.new($` + replacement + $')
	else
		raise "Template target <%%%p%%> not found" % target
	end
end