⚲
Project
General
Profile
Sign in
Register
Home
Projects
Help
Search
:
Ruby master
All Projects
Ruby
»
Ruby master
Overview
Activity
Roadmap
Issues
Repository
Like
Download (882 Bytes)
Feature #11936
» sample.rb
Sample code to add a new token -
k0kubun (Takashi Kokubun)
, 01/01/2016 06:34 AM
require
'erb'
class
ERB
class
HTML
<
ERB
class
HTMLCompiler
<
Compiler
class
HTMLScanner
<
Compiler
::
SimpleScanner
def
stags
[
'<%=='
]
+
super
end
end
def
make_scanner
(
src
)
HTMLScanner
.
new
(
src
,
@trim_mode
,
@percent
)
end
def
compile_stag
(
stag
,
out
,
scanner
)
case
stag
when
'<%=='
scanner
.
stag
=
stag
add_put_cmd
(
out
,
content
)
if
content
.
size
>
0
self
.
content
=
''
else
super
end
end
def
compile_content
(
stag
,
out
)
case
stag
when
'<%=='
out
.
push
(
"
#{
@insert_cmd
}
(::ERB::Util.html_escape(
#{
content
}
))"
)
else
super
end
end
end
def
make_compiler
(
trim_mode
)
HTMLCompiler
.
new
(
trim_mode
)
end
end
end
# ERB::HTML.new('<%== "<>" %>').result #=> "<>"
« Previous
1
2
Next »
(1-1/2)
Loading...