From 9cca5a4646d22fc19fee9c32d868b5b0e66ee20d Mon Sep 17 00:00:00 2001 From: Ilya Grigorik Date: Wed, 26 Oct 2011 18:11:48 -0700 Subject: [PATCH] fixup readme and explain what's going on under the hood --- README.md | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index d3ebfa7..bc13a4e 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,13 @@ # Runtime Contextual Autoescaper -A JRuby wrapper for [Mike Samuel's contextual HTML autoescaper](https://github.com/mikesamuel/html-contextual-autoescaper-java). A quick example of the escaper at work: +A JRuby wrapper for [Mike Samuel's contextual HTML autoescaper](https://github.com/mikesamuel/html-contextual-autoescaper-java). -```ruby -<% def helper(obj); "Hello, \#{obj['world']}"; end %> +## Example + +First, let's define an Erb template: + +```erb +<% def helper(obj); "Hello, #{obj['world']}"; end %>
<%= helper(object) %> @@ -15,6 +19,7 @@ A JRuby wrapper for [Mike Samuel's contextual HTML autoescaper](https://github.c ``` Let's load the template and execute it: + ```ruby template = Erubis::ContextualEruby.new(template_string) @@ -24,7 +29,7 @@ puts template.result(binding()) Output: -``` +```html
Hello, <Cincinnati>