-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Wlodek Bzyl
committed
Apr 14, 2009
0 parents
commit dc30d1f
Showing
8 changed files
with
94 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
*.gem |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
## Sinatra Extensions | ||
|
||
[Typo](http://www.sinatrarb.com/extensions.html): | ||
|
||
require 'sinatra/base' | ||
require 'rack/utils' # added | ||
module Sinatra | ||
module HTMLEscapeHelper | ||
def h(text) | ||
Rake::Utils.escape_html(text) #<-- Rack::Utils.escape_html(text) | ||
end | ||
|
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
require 'rubygems' | ||
require 'sinatra' | ||
require 'sinatra/rdiscount' | ||
|
||
get "/hello" do | ||
h "1 < 2" # => "1 < 2" | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
require 'sinatra/base' | ||
require 'rack/utils' | ||
|
||
module Sinatra | ||
module HTMLEscapeHelper | ||
def h(text) | ||
Rack::Utils.escape_html(text) | ||
end | ||
end | ||
|
||
helpers HTMLEscapeHelper | ||
end | ||
|
||
module Sinatra | ||
module RDiscountTemplate | ||
|
||
def rdiscount(template, options={}, locals={}) | ||
require 'rdiscount' unless defined? ::RDiscount | ||
render :rdiscount, template, options, locals | ||
end | ||
|
||
private | ||
|
||
def render_rdiscount(template, data, options, locals, &block) | ||
original_out_buf = @_out_buf | ||
data = data.call if data.kind_of? Proc | ||
instance = ::ERB.new(data, nil, nil, '@_out_buf') | ||
locals_assigns = locals.to_a.collect { |k,v| "#{k} = locals[:#{k}]" } | ||
|
||
src = "#{locals_assigns.join("\n")}\n#{instance.src}" | ||
eval src, binding, '(__ERB__)', locals_assigns.length + 1 | ||
@_out_buf, result = original_out_buf, @_out_buf | ||
result | ||
end | ||
|
||
end | ||
|
||
helpers RDiscountTemplate | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# -*- coding: utf-8 -*- | ||
|
||
Gem::Specification.new do |s| | ||
s.specification_version = 2 if s.respond_to? :specification_version= | ||
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version= | ||
|
||
s.name = 'sinatra-rdiscount' | ||
s.version = '0.0.2' | ||
s.date = '2009-03-31' | ||
|
||
s.description = "RDiscount templates for Sinatra applications" | ||
s.summary = "RDiscount..." | ||
|
||
s.authors = ["Włodek Bzyl"] | ||
s.email = "matwb@univ.gda.pl" | ||
|
||
s.files = %w[ | ||
LICENSE | ||
README.markdown | ||
Rakefile | ||
lib/sinatra/rdiscount.rb | ||
sinatra-rdiscount.gemspec | ||
test/spec_sinatra_rdiscount.rb | ||
] | ||
s.require_paths = %w[lib] | ||
|
||
s.add_dependency 'rdiscount', '>= 1.3.4' | ||
|
||
s.has_rdoc = false | ||
s.homepage = "http://sinatra.rubyforge.org" | ||
|
||
s.rubyforge_project = 'sinatra-rdiscount' | ||
s.rubygems_version = '1.3.1' | ||
end |
Empty file.