The Enkoder Plugin for Ruby on Rails
That’s right, you can now include the full functionality of the Enkoder (including on-the-fly enkoding) right in your own Rails applications.
What is the Enkoder?
You can download the Enkoder plugin as a zip archive. Then, just unzip the archive and drop the
enkoder folder it creates into your project’s
There are two methods:
enkode( html )
The second method is:
enkode_mail( email, link_text, title_text, subject )
This method takes an email address, the text to show to the viewer, optional title text (what’s seen when somebody hovers over the link), and optional subject for the email, and returns an enkoded email address link.
To enkode a single email address, you could just do this:
&lt;%= enkode_mail('email@example.com','click here') %&gt;
&lt;a href="mailto:"firstname.lastname@example.org" title=""&gt;click here&lt;/a&gt;
Of course we can also enkode many email addresses on the fly:
&lt;% @users.each do |user| %&gt; &lt;p&gt;&lt;%= enkode_mail(@user.email,@user.name) %&gt;&lt;/p&gt; &lt;% end %&gt;
To enkode a snippet of XHTML, we can do:
&lt;%= enkode( "&lt;p&gt;This block will be hidden from spambots.&lt;/p&gt;" ) %&gt;
We could have anything we wanted in that block, XHTML, links, email addresses, etc.
For more information, usage details, and additional examples, please visit the Hivelogic Enkoder page.
I’d like to share my gratitude to The Guru, wherever he dwells, for his assistance with the latest Enkoder algorithm. Without his help, we’d still be in the stone-ages, using easily-decoded HTML entity conversions or performing voodoo rituals to try and ward-off spam.