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!, #to_unix

Class Method Details

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



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

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



141
142
143
144
145
146
147
148
# File 'lib/coderay/encoders/html/output.rb', line 141

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