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>