Class: Tenjin::SafeTemplate
Constant Summary collapse
- ESCAPE_FUNCTION =
'safe_escape'
Constants inherited from Template
Instance Attribute Summary
Attributes inherited from Template
#_last_checked_at, #args, #escapefunc, #filename, #initbuf, #newline, #script, #timestamp
Instance Method Summary collapse
-
#escape_str(str) ⇒ Object
escape ‘#’ in addition ‘\’ and ‘`’.
-
#initialize(filename = nil, options = {}) ⇒ SafeTemplate
constructor
A new instance of SafeTemplate.
Methods inherited from Template
TRACE=, #convert, #convert_file, #finish_buf_expr, #init_buf_expr, #render
Constructor Details
#initialize(filename = nil, options = {}) ⇒ SafeTemplate
Returns a new instance of SafeTemplate.
971 972 973 974 975 |
# File 'lib/tenjin.rb', line 971 def initialize(filename=nil, ={}) , filename = filename, nil if filename.is_a?(Hash) [:escapefunc] ||= 'safe_escape' super(filename, ) end |
Instance Method Details
#escape_str(str) ⇒ Object
escape ‘#’ in addition ‘\’ and ‘`’
978 979 980 981 982 |
# File 'lib/tenjin.rb', line 978 def escape_str(str) str.gsub!(/[`\#\\]/, '\\\\\&') str.gsub!(/\r\n/, "\\r\r\n") if @newline == "\r\n" return str end |