tma / html_helpers

Rails Plugin with Helpers to en- and decode HTML Entities
Other
12 stars 5 forks source link

HTML::EntityCoder

This plugin lets you encode and decode (UTF-8) strings using HTML entities. Two new methods will be automatically available in your views:

<%= encode_entities("Über geek") %> => "Über geek"

<%= decode_entities("Über geek") %> => "Über geek"

Using Anywhere

Now it's possible to include the helpers in other classes easily by just including HTML::EntityCoder in your class.

If you really need to to use the helpers in a model you can do it like this:

class Person < ActiveRecord::Base include HTML::EntityCoder end

or a controller:

class PersonController < ApplicationController include HTML::EntityCoder end

etc.

Note: Don't feed the helpers with anything else but UTF-8. If you really need to, convert your string to UTF-8 first using Iconv (http://www.ruby-doc.org/stdlib/libdoc/iconv/rdoc/index.html)

A basic test unit is included.

HTMLHelpers is copyright (c) 2006 Ruben Nine (ruben.nine@gmail.com), released under the MIT license HTMLEntities is copyright (c) 2005-2006 Paul Battley, released under the MIT license