Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Jekyll::HamlHelpers module with h() and link_to() methods.

  • Loading branch information...
commit ab5f86eea4213d8279e76e8a4277d28a1b8119c6 1 parent 3f8aa88
@henrik henrik authored
View
2  lib/jekyll/convertible.rb
@@ -75,6 +75,8 @@ def do_layout(payload, layouts)
context = OpenStruct.new(
:site => OpenStruct.new(payload["site"]),
:page => OpenStruct.new(payload["page"]))
+ context.extend(HamlHelpers)
+
self.transform
self.content = self.content.render(context)
else
View
15 lib/jekyll/haml_helpers.rb
@@ -0,0 +1,15 @@
+require 'cgi'
+
+module Jekyll
+ module HamlHelpers
+
+ def h(text)
+ CGI.escapeHTML(text)
+ end
+
+ def link_to(text, url)
+ %{<a href="#{h url}">#{text}</a>}
+ end
+
+ end
+end
View
1  lib/jekyll/site.rb
@@ -48,6 +48,7 @@ def setup
begin
require 'haml'
require 'ostruct'
+ require 'jekyll/haml_helpers'
puts 'Enabled Haml'
rescue LoadError
puts 'You must have the haml gem installed first'
Please sign in to comment.
Something went wrong with that request. Please try again.