Edit File by line
/home/barbar84/public_h.../wp-conte.../plugins/sujqvwi/AnonR/smanonr..../opt/alt/ruby27/share/ruby
File: erb.rb
# -*- coding: us-ascii -*-
[0] Fix | Delete
# frozen_string_literal: true
[1] Fix | Delete
# = ERB -- Ruby Templating
[2] Fix | Delete
#
[3] Fix | Delete
# Author:: Masatoshi SEKI
[4] Fix | Delete
# Documentation:: James Edward Gray II, Gavin Sinclair, and Simon Chiang
[5] Fix | Delete
#
[6] Fix | Delete
# See ERB for primary documentation and ERB::Util for a couple of utility
[7] Fix | Delete
# routines.
[8] Fix | Delete
#
[9] Fix | Delete
# Copyright (c) 1999-2000,2002,2003 Masatoshi SEKI
[10] Fix | Delete
#
[11] Fix | Delete
# You can redistribute it and/or modify it under the same terms as Ruby.
[12] Fix | Delete
[13] Fix | Delete
require "cgi/util"
[14] Fix | Delete
[15] Fix | Delete
#
[16] Fix | Delete
# = ERB -- Ruby Templating
[17] Fix | Delete
#
[18] Fix | Delete
# == Introduction
[19] Fix | Delete
#
[20] Fix | Delete
# ERB provides an easy to use but powerful templating system for Ruby. Using
[21] Fix | Delete
# ERB, actual Ruby code can be added to any plain text document for the
[22] Fix | Delete
# purposes of generating document information details and/or flow control.
[23] Fix | Delete
#
[24] Fix | Delete
# A very simple example is this:
[25] Fix | Delete
#
[26] Fix | Delete
# require 'erb'
[27] Fix | Delete
#
[28] Fix | Delete
# x = 42
[29] Fix | Delete
# template = ERB.new <<-EOF
[30] Fix | Delete
# The value of x is: <%= x %>
[31] Fix | Delete
# EOF
[32] Fix | Delete
# puts template.result(binding)
[33] Fix | Delete
#
[34] Fix | Delete
# <em>Prints:</em> The value of x is: 42
[35] Fix | Delete
#
[36] Fix | Delete
# More complex examples are given below.
[37] Fix | Delete
#
[38] Fix | Delete
#
[39] Fix | Delete
# == Recognized Tags
[40] Fix | Delete
#
[41] Fix | Delete
# ERB recognizes certain tags in the provided template and converts them based
[42] Fix | Delete
# on the rules below:
[43] Fix | Delete
#
[44] Fix | Delete
# <% Ruby code -- inline with output %>
[45] Fix | Delete
# <%= Ruby expression -- replace with result %>
[46] Fix | Delete
# <%# comment -- ignored -- useful in testing %>
[47] Fix | Delete
# % a line of Ruby code -- treated as <% line %> (optional -- see ERB.new)
[48] Fix | Delete
# %% replaced with % if first thing on a line and % processing is used
[49] Fix | Delete
# <%% or %%> -- replace with <% or %> respectively
[50] Fix | Delete
#
[51] Fix | Delete
# All other text is passed through ERB filtering unchanged.
[52] Fix | Delete
#
[53] Fix | Delete
#
[54] Fix | Delete
# == Options
[55] Fix | Delete
#
[56] Fix | Delete
# There are several settings you can change when you use ERB:
[57] Fix | Delete
# * the nature of the tags that are recognized;
[58] Fix | Delete
# * the binding used to resolve local variables in the template.
[59] Fix | Delete
#
[60] Fix | Delete
# See the ERB.new and ERB#result methods for more detail.
[61] Fix | Delete
#
[62] Fix | Delete
# == Character encodings
[63] Fix | Delete
#
[64] Fix | Delete
# ERB (or Ruby code generated by ERB) returns a string in the same
[65] Fix | Delete
# character encoding as the input string. When the input string has
[66] Fix | Delete
# a magic comment, however, it returns a string in the encoding specified
[67] Fix | Delete
# by the magic comment.
[68] Fix | Delete
#
[69] Fix | Delete
# # -*- coding: utf-8 -*-
[70] Fix | Delete
# require 'erb'
[71] Fix | Delete
#
[72] Fix | Delete
# template = ERB.new <<EOF
[73] Fix | Delete
# <%#-*- coding: Big5 -*-%>
[74] Fix | Delete
# \_\_ENCODING\_\_ is <%= \_\_ENCODING\_\_ %>.
[75] Fix | Delete
# EOF
[76] Fix | Delete
# puts template.result
[77] Fix | Delete
#
[78] Fix | Delete
# <em>Prints:</em> \_\_ENCODING\_\_ is Big5.
[79] Fix | Delete
#
[80] Fix | Delete
#
[81] Fix | Delete
# == Examples
[82] Fix | Delete
#
[83] Fix | Delete
# === Plain Text
[84] Fix | Delete
#
[85] Fix | Delete
# ERB is useful for any generic templating situation. Note that in this example, we use the
[86] Fix | Delete
# convenient "% at start of line" tag, and we quote the template literally with
[87] Fix | Delete
# <tt>%q{...}</tt> to avoid trouble with the backslash.
[88] Fix | Delete
#
[89] Fix | Delete
# require "erb"
[90] Fix | Delete
#
[91] Fix | Delete
# # Create template.
[92] Fix | Delete
# template = %q{
[93] Fix | Delete
# From: James Edward Gray II <james@grayproductions.net>
[94] Fix | Delete
# To: <%= to %>
[95] Fix | Delete
# Subject: Addressing Needs
[96] Fix | Delete
#
[97] Fix | Delete
# <%= to[/\w+/] %>:
[98] Fix | Delete
#
[99] Fix | Delete
# Just wanted to send a quick note assuring that your needs are being
[100] Fix | Delete
# addressed.
[101] Fix | Delete
#
[102] Fix | Delete
# I want you to know that my team will keep working on the issues,
[103] Fix | Delete
# especially:
[104] Fix | Delete
#
[105] Fix | Delete
# <%# ignore numerous minor requests -- focus on priorities %>
[106] Fix | Delete
# % priorities.each do |priority|
[107] Fix | Delete
# * <%= priority %>
[108] Fix | Delete
# % end
[109] Fix | Delete
#
[110] Fix | Delete
# Thanks for your patience.
[111] Fix | Delete
#
[112] Fix | Delete
# James Edward Gray II
[113] Fix | Delete
# }.gsub(/^ /, '')
[114] Fix | Delete
#
[115] Fix | Delete
# message = ERB.new(template, trim_mode: "%<>")
[116] Fix | Delete
#
[117] Fix | Delete
# # Set up template data.
[118] Fix | Delete
# to = "Community Spokesman <spokesman@ruby_community.org>"
[119] Fix | Delete
# priorities = [ "Run Ruby Quiz",
[120] Fix | Delete
# "Document Modules",
[121] Fix | Delete
# "Answer Questions on Ruby Talk" ]
[122] Fix | Delete
#
[123] Fix | Delete
# # Produce result.
[124] Fix | Delete
# email = message.result
[125] Fix | Delete
# puts email
[126] Fix | Delete
#
[127] Fix | Delete
# <i>Generates:</i>
[128] Fix | Delete
#
[129] Fix | Delete
# From: James Edward Gray II <james@grayproductions.net>
[130] Fix | Delete
# To: Community Spokesman <spokesman@ruby_community.org>
[131] Fix | Delete
# Subject: Addressing Needs
[132] Fix | Delete
#
[133] Fix | Delete
# Community:
[134] Fix | Delete
#
[135] Fix | Delete
# Just wanted to send a quick note assuring that your needs are being addressed.
[136] Fix | Delete
#
[137] Fix | Delete
# I want you to know that my team will keep working on the issues, especially:
[138] Fix | Delete
#
[139] Fix | Delete
# * Run Ruby Quiz
[140] Fix | Delete
# * Document Modules
[141] Fix | Delete
# * Answer Questions on Ruby Talk
[142] Fix | Delete
#
[143] Fix | Delete
# Thanks for your patience.
[144] Fix | Delete
#
[145] Fix | Delete
# James Edward Gray II
[146] Fix | Delete
#
[147] Fix | Delete
# === Ruby in HTML
[148] Fix | Delete
#
[149] Fix | Delete
# ERB is often used in <tt>.rhtml</tt> files (HTML with embedded Ruby). Notice the need in
[150] Fix | Delete
# this example to provide a special binding when the template is run, so that the instance
[151] Fix | Delete
# variables in the Product object can be resolved.
[152] Fix | Delete
#
[153] Fix | Delete
# require "erb"
[154] Fix | Delete
#
[155] Fix | Delete
# # Build template data class.
[156] Fix | Delete
# class Product
[157] Fix | Delete
# def initialize( code, name, desc, cost )
[158] Fix | Delete
# @code = code
[159] Fix | Delete
# @name = name
[160] Fix | Delete
# @desc = desc
[161] Fix | Delete
# @cost = cost
[162] Fix | Delete
#
[163] Fix | Delete
# @features = [ ]
[164] Fix | Delete
# end
[165] Fix | Delete
#
[166] Fix | Delete
# def add_feature( feature )
[167] Fix | Delete
# @features << feature
[168] Fix | Delete
# end
[169] Fix | Delete
#
[170] Fix | Delete
# # Support templating of member data.
[171] Fix | Delete
# def get_binding
[172] Fix | Delete
# binding
[173] Fix | Delete
# end
[174] Fix | Delete
#
[175] Fix | Delete
# # ...
[176] Fix | Delete
# end
[177] Fix | Delete
#
[178] Fix | Delete
# # Create template.
[179] Fix | Delete
# template = %{
[180] Fix | Delete
# <html>
[181] Fix | Delete
# <head><title>Ruby Toys -- <%= @name %></title></head>
[182] Fix | Delete
# <body>
[183] Fix | Delete
#
[184] Fix | Delete
# <h1><%= @name %> (<%= @code %>)</h1>
[185] Fix | Delete
# <p><%= @desc %></p>
[186] Fix | Delete
#
[187] Fix | Delete
# <ul>
[188] Fix | Delete
# <% @features.each do |f| %>
[189] Fix | Delete
# <li><b><%= f %></b></li>
[190] Fix | Delete
# <% end %>
[191] Fix | Delete
# </ul>
[192] Fix | Delete
#
[193] Fix | Delete
# <p>
[194] Fix | Delete
# <% if @cost < 10 %>
[195] Fix | Delete
# <b>Only <%= @cost %>!!!</b>
[196] Fix | Delete
# <% else %>
[197] Fix | Delete
# Call for a price, today!
[198] Fix | Delete
# <% end %>
[199] Fix | Delete
# </p>
[200] Fix | Delete
#
[201] Fix | Delete
# </body>
[202] Fix | Delete
# </html>
[203] Fix | Delete
# }.gsub(/^ /, '')
[204] Fix | Delete
#
[205] Fix | Delete
# rhtml = ERB.new(template)
[206] Fix | Delete
#
[207] Fix | Delete
# # Set up template data.
[208] Fix | Delete
# toy = Product.new( "TZ-1002",
[209] Fix | Delete
# "Rubysapien",
[210] Fix | Delete
# "Geek's Best Friend! Responds to Ruby commands...",
[211] Fix | Delete
# 999.95 )
[212] Fix | Delete
# toy.add_feature("Listens for verbal commands in the Ruby language!")
[213] Fix | Delete
# toy.add_feature("Ignores Perl, Java, and all C variants.")
[214] Fix | Delete
# toy.add_feature("Karate-Chop Action!!!")
[215] Fix | Delete
# toy.add_feature("Matz signature on left leg.")
[216] Fix | Delete
# toy.add_feature("Gem studded eyes... Rubies, of course!")
[217] Fix | Delete
#
[218] Fix | Delete
# # Produce result.
[219] Fix | Delete
# rhtml.run(toy.get_binding)
[220] Fix | Delete
#
[221] Fix | Delete
# <i>Generates (some blank lines removed):</i>
[222] Fix | Delete
#
[223] Fix | Delete
# <html>
[224] Fix | Delete
# <head><title>Ruby Toys -- Rubysapien</title></head>
[225] Fix | Delete
# <body>
[226] Fix | Delete
#
[227] Fix | Delete
# <h1>Rubysapien (TZ-1002)</h1>
[228] Fix | Delete
# <p>Geek's Best Friend! Responds to Ruby commands...</p>
[229] Fix | Delete
#
[230] Fix | Delete
# <ul>
[231] Fix | Delete
# <li><b>Listens for verbal commands in the Ruby language!</b></li>
[232] Fix | Delete
# <li><b>Ignores Perl, Java, and all C variants.</b></li>
[233] Fix | Delete
# <li><b>Karate-Chop Action!!!</b></li>
[234] Fix | Delete
# <li><b>Matz signature on left leg.</b></li>
[235] Fix | Delete
# <li><b>Gem studded eyes... Rubies, of course!</b></li>
[236] Fix | Delete
# </ul>
[237] Fix | Delete
#
[238] Fix | Delete
# <p>
[239] Fix | Delete
# Call for a price, today!
[240] Fix | Delete
# </p>
[241] Fix | Delete
#
[242] Fix | Delete
# </body>
[243] Fix | Delete
# </html>
[244] Fix | Delete
#
[245] Fix | Delete
#
[246] Fix | Delete
# == Notes
[247] Fix | Delete
#
[248] Fix | Delete
# There are a variety of templating solutions available in various Ruby projects.
[249] Fix | Delete
# For example, RDoc, distributed with Ruby, uses its own template engine, which
[250] Fix | Delete
# can be reused elsewhere.
[251] Fix | Delete
#
[252] Fix | Delete
# Other popular engines could be found in the corresponding
[253] Fix | Delete
# {Category}[https://www.ruby-toolbox.com/categories/template_engines] of
[254] Fix | Delete
# The Ruby Toolbox.
[255] Fix | Delete
#
[256] Fix | Delete
class ERB
[257] Fix | Delete
Revision = '$Date:: $' # :nodoc: #'
[258] Fix | Delete
[259] Fix | Delete
# Returns revision information for the erb.rb module.
[260] Fix | Delete
def self.version
[261] Fix | Delete
"erb.rb [2.2.0 #{ERB::Revision.split[1]}]"
[262] Fix | Delete
end
[263] Fix | Delete
end
[264] Fix | Delete
[265] Fix | Delete
#--
[266] Fix | Delete
# ERB::Compiler
[267] Fix | Delete
class ERB
[268] Fix | Delete
# = ERB::Compiler
[269] Fix | Delete
#
[270] Fix | Delete
# Compiles ERB templates into Ruby code; the compiled code produces the
[271] Fix | Delete
# template result when evaluated. ERB::Compiler provides hooks to define how
[272] Fix | Delete
# generated output is handled.
[273] Fix | Delete
#
[274] Fix | Delete
# Internally ERB does something like this to generate the code returned by
[275] Fix | Delete
# ERB#src:
[276] Fix | Delete
#
[277] Fix | Delete
# compiler = ERB::Compiler.new('<>')
[278] Fix | Delete
# compiler.pre_cmd = ["_erbout=+''"]
[279] Fix | Delete
# compiler.put_cmd = "_erbout.<<"
[280] Fix | Delete
# compiler.insert_cmd = "_erbout.<<"
[281] Fix | Delete
# compiler.post_cmd = ["_erbout"]
[282] Fix | Delete
#
[283] Fix | Delete
# code, enc = compiler.compile("Got <%= obj %>!\n")
[284] Fix | Delete
# puts code
[285] Fix | Delete
#
[286] Fix | Delete
# <i>Generates</i>:
[287] Fix | Delete
#
[288] Fix | Delete
# #coding:UTF-8
[289] Fix | Delete
# _erbout=+''; _erbout.<< "Got ".freeze; _erbout.<<(( obj ).to_s); _erbout.<< "!\n".freeze; _erbout
[290] Fix | Delete
#
[291] Fix | Delete
# By default the output is sent to the print method. For example:
[292] Fix | Delete
#
[293] Fix | Delete
# compiler = ERB::Compiler.new('<>')
[294] Fix | Delete
# code, enc = compiler.compile("Got <%= obj %>!\n")
[295] Fix | Delete
# puts code
[296] Fix | Delete
#
[297] Fix | Delete
# <i>Generates</i>:
[298] Fix | Delete
#
[299] Fix | Delete
# #coding:UTF-8
[300] Fix | Delete
# print "Got ".freeze; print(( obj ).to_s); print "!\n".freeze
[301] Fix | Delete
#
[302] Fix | Delete
# == Evaluation
[303] Fix | Delete
#
[304] Fix | Delete
# The compiled code can be used in any context where the names in the code
[305] Fix | Delete
# correctly resolve. Using the last example, each of these print 'Got It!'
[306] Fix | Delete
#
[307] Fix | Delete
# Evaluate using a variable:
[308] Fix | Delete
#
[309] Fix | Delete
# obj = 'It'
[310] Fix | Delete
# eval code
[311] Fix | Delete
#
[312] Fix | Delete
# Evaluate using an input:
[313] Fix | Delete
#
[314] Fix | Delete
# mod = Module.new
[315] Fix | Delete
# mod.module_eval %{
[316] Fix | Delete
# def get(obj)
[317] Fix | Delete
# #{code}
[318] Fix | Delete
# end
[319] Fix | Delete
# }
[320] Fix | Delete
# extend mod
[321] Fix | Delete
# get('It')
[322] Fix | Delete
#
[323] Fix | Delete
# Evaluate using an accessor:
[324] Fix | Delete
#
[325] Fix | Delete
# klass = Class.new Object
[326] Fix | Delete
# klass.class_eval %{
[327] Fix | Delete
# attr_accessor :obj
[328] Fix | Delete
# def initialize(obj)
[329] Fix | Delete
# @obj = obj
[330] Fix | Delete
# end
[331] Fix | Delete
# def get_it
[332] Fix | Delete
# #{code}
[333] Fix | Delete
# end
[334] Fix | Delete
# }
[335] Fix | Delete
# klass.new('It').get_it
[336] Fix | Delete
#
[337] Fix | Delete
# Good! See also ERB#def_method, ERB#def_module, and ERB#def_class.
[338] Fix | Delete
class Compiler # :nodoc:
[339] Fix | Delete
class PercentLine # :nodoc:
[340] Fix | Delete
def initialize(str)
[341] Fix | Delete
@value = str
[342] Fix | Delete
end
[343] Fix | Delete
attr_reader :value
[344] Fix | Delete
alias :to_s :value
[345] Fix | Delete
end
[346] Fix | Delete
[347] Fix | Delete
class Scanner # :nodoc:
[348] Fix | Delete
@scanner_map = {}
[349] Fix | Delete
class << self
[350] Fix | Delete
def register_scanner(klass, trim_mode, percent)
[351] Fix | Delete
@scanner_map[[trim_mode, percent]] = klass
[352] Fix | Delete
end
[353] Fix | Delete
alias :regist_scanner :register_scanner
[354] Fix | Delete
end
[355] Fix | Delete
[356] Fix | Delete
def self.default_scanner=(klass)
[357] Fix | Delete
@default_scanner = klass
[358] Fix | Delete
end
[359] Fix | Delete
[360] Fix | Delete
def self.make_scanner(src, trim_mode, percent)
[361] Fix | Delete
klass = @scanner_map.fetch([trim_mode, percent], @default_scanner)
[362] Fix | Delete
klass.new(src, trim_mode, percent)
[363] Fix | Delete
end
[364] Fix | Delete
[365] Fix | Delete
DEFAULT_STAGS = %w(<%% <%= <%# <%).freeze
[366] Fix | Delete
DEFAULT_ETAGS = %w(%%> %>).freeze
[367] Fix | Delete
def initialize(src, trim_mode, percent)
[368] Fix | Delete
@src = src
[369] Fix | Delete
@stag = nil
[370] Fix | Delete
@stags = DEFAULT_STAGS
[371] Fix | Delete
@etags = DEFAULT_ETAGS
[372] Fix | Delete
end
[373] Fix | Delete
attr_accessor :stag
[374] Fix | Delete
attr_reader :stags, :etags
[375] Fix | Delete
[376] Fix | Delete
def scan; end
[377] Fix | Delete
end
[378] Fix | Delete
[379] Fix | Delete
class TrimScanner < Scanner # :nodoc:
[380] Fix | Delete
def initialize(src, trim_mode, percent)
[381] Fix | Delete
super
[382] Fix | Delete
@trim_mode = trim_mode
[383] Fix | Delete
@percent = percent
[384] Fix | Delete
if @trim_mode == '>'
[385] Fix | Delete
@scan_reg = /(.*?)(%>\r?\n|#{(stags + etags).join('|')}|\n|\z)/m
[386] Fix | Delete
@scan_line = self.method(:trim_line1)
[387] Fix | Delete
elsif @trim_mode == '<>'
[388] Fix | Delete
@scan_reg = /(.*?)(%>\r?\n|#{(stags + etags).join('|')}|\n|\z)/m
[389] Fix | Delete
@scan_line = self.method(:trim_line2)
[390] Fix | Delete
elsif @trim_mode == '-'
[391] Fix | Delete
@scan_reg = /(.*?)(^[ \t]*<%\-|<%\-|-%>\r?\n|-%>|#{(stags + etags).join('|')}|\z)/m
[392] Fix | Delete
@scan_line = self.method(:explicit_trim_line)
[393] Fix | Delete
else
[394] Fix | Delete
@scan_reg = /(.*?)(#{(stags + etags).join('|')}|\n|\z)/m
[395] Fix | Delete
@scan_line = self.method(:scan_line)
[396] Fix | Delete
end
[397] Fix | Delete
end
[398] Fix | Delete
[399] Fix | Delete
def scan(&block)
[400] Fix | Delete
@stag = nil
[401] Fix | Delete
if @percent
[402] Fix | Delete
@src.each_line do |line|
[403] Fix | Delete
percent_line(line, &block)
[404] Fix | Delete
end
[405] Fix | Delete
else
[406] Fix | Delete
@scan_line.call(@src, &block)
[407] Fix | Delete
end
[408] Fix | Delete
nil
[409] Fix | Delete
end
[410] Fix | Delete
[411] Fix | Delete
def percent_line(line, &block)
[412] Fix | Delete
if @stag || line[0] != ?%
[413] Fix | Delete
return @scan_line.call(line, &block)
[414] Fix | Delete
end
[415] Fix | Delete
[416] Fix | Delete
line[0] = ''
[417] Fix | Delete
if line[0] == ?%
[418] Fix | Delete
@scan_line.call(line, &block)
[419] Fix | Delete
else
[420] Fix | Delete
yield(PercentLine.new(line.chomp))
[421] Fix | Delete
end
[422] Fix | Delete
end
[423] Fix | Delete
[424] Fix | Delete
def scan_line(line)
[425] Fix | Delete
line.scan(@scan_reg) do |tokens|
[426] Fix | Delete
tokens.each do |token|
[427] Fix | Delete
next if token.empty?
[428] Fix | Delete
yield(token)
[429] Fix | Delete
end
[430] Fix | Delete
end
[431] Fix | Delete
end
[432] Fix | Delete
[433] Fix | Delete
def trim_line1(line)
[434] Fix | Delete
line.scan(@scan_reg) do |tokens|
[435] Fix | Delete
tokens.each do |token|
[436] Fix | Delete
next if token.empty?
[437] Fix | Delete
if token == "%>\n" || token == "%>\r\n"
[438] Fix | Delete
yield('%>')
[439] Fix | Delete
yield(:cr)
[440] Fix | Delete
else
[441] Fix | Delete
yield(token)
[442] Fix | Delete
end
[443] Fix | Delete
end
[444] Fix | Delete
end
[445] Fix | Delete
end
[446] Fix | Delete
[447] Fix | Delete
def trim_line2(line)
[448] Fix | Delete
head = nil
[449] Fix | Delete
line.scan(@scan_reg) do |tokens|
[450] Fix | Delete
tokens.each do |token|
[451] Fix | Delete
next if token.empty?
[452] Fix | Delete
head = token unless head
[453] Fix | Delete
if token == "%>\n" || token == "%>\r\n"
[454] Fix | Delete
yield('%>')
[455] Fix | Delete
if is_erb_stag?(head)
[456] Fix | Delete
yield(:cr)
[457] Fix | Delete
else
[458] Fix | Delete
yield("\n")
[459] Fix | Delete
end
[460] Fix | Delete
head = nil
[461] Fix | Delete
else
[462] Fix | Delete
yield(token)
[463] Fix | Delete
head = nil if token == "\n"
[464] Fix | Delete
end
[465] Fix | Delete
end
[466] Fix | Delete
end
[467] Fix | Delete
end
[468] Fix | Delete
[469] Fix | Delete
def explicit_trim_line(line)
[470] Fix | Delete
line.scan(@scan_reg) do |tokens|
[471] Fix | Delete
tokens.each do |token|
[472] Fix | Delete
next if token.empty?
[473] Fix | Delete
if @stag.nil? && /[ \t]*<%-/ =~ token
[474] Fix | Delete
yield('<%')
[475] Fix | Delete
elsif @stag && (token == "-%>\n" || token == "-%>\r\n")
[476] Fix | Delete
yield('%>')
[477] Fix | Delete
yield(:cr)
[478] Fix | Delete
elsif @stag && token == '-%>'
[479] Fix | Delete
yield('%>')
[480] Fix | Delete
else
[481] Fix | Delete
yield(token)
[482] Fix | Delete
end
[483] Fix | Delete
end
[484] Fix | Delete
end
[485] Fix | Delete
end
[486] Fix | Delete
[487] Fix | Delete
ERB_STAG = %w(<%= <%# <%)
[488] Fix | Delete
def is_erb_stag?(s)
[489] Fix | Delete
ERB_STAG.member?(s)
[490] Fix | Delete
end
[491] Fix | Delete
end
[492] Fix | Delete
[493] Fix | Delete
Scanner.default_scanner = TrimScanner
[494] Fix | Delete
[495] Fix | Delete
begin
[496] Fix | Delete
require 'strscan'
[497] Fix | Delete
rescue LoadError
[498] Fix | Delete
else
[499] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function