require "amrita/template" include Amrita tmpl = TemplateText.new %q[

xxx

] data = { :body=>"I want to insert new line.
But I can't" } tmpl.expand(STDOUT, data) #

I want to insert new line.<br>But I can't

puts data = { :body=>noescape { "I can insert new line
with escape { ... }
But it may be dangerous" } } tmpl.expand(STDOUT, data) #

I can insert new line
with escape { ... }
But it may be dangerous

puts data = { # The attacker expected amrita to print

XSS attack

But amrita sanitize it!

:body=>a(:yyy=>%q[">

XSS attack hereBut amrita sanitize it!

puts tmpl = TemplateText.new %q[href is treated in a special way] data = { :body=>a(:href=>%q[javascript:alert('hello')]) } tmpl.expand(STDOUT, data) # href is treated in a special way puts