middleman 0.5.5 → 0.9.0.pre
Sign up to get free protection for your applications and to get access to all the features.
- data/.document +1 -2
- data/.gitignore +3 -2
- data/LICENSE +0 -0
- data/README.rdoc +4 -0
- data/Rakefile +28 -36
- data/VERSION +1 -1
- data/bin/mm-build +7 -113
- data/bin/mm-init +11 -5
- data/bin/mm-server +56 -3
- data/features/asset_host.feature +12 -0
- data/features/automatic_image_sizes.feature +14 -0
- data/features/cache_buster.feature +22 -0
- data/features/generator.feature +8 -0
- data/features/minify_css.feature +22 -0
- data/features/minify_javascript.feature +12 -0
- data/features/page_alias_and_layouts.feature +12 -0
- data/features/relative_assets.feature +12 -0
- data/features/step_definitions/asset_host_steps.rb +7 -0
- data/features/step_definitions/env.rb +3 -0
- data/features/step_definitions/generator_steps.rb +24 -0
- data/features/step_definitions/middleman_steps.rb +28 -0
- data/features/step_definitions/page_layout_steps.rb +13 -0
- data/lib/middleman.rb +6 -132
- data/lib/middleman/assets.rb +33 -0
- data/lib/middleman/base.rb +147 -0
- data/lib/middleman/builder.rb +59 -0
- data/lib/middleman/config.ru +2 -0
- data/lib/middleman/features.rb +39 -0
- data/lib/middleman/features/asset_host.rb +21 -0
- data/lib/middleman/features/automatic_image_sizes.rb +31 -0
- data/lib/middleman/features/automatic_image_sizes/fastimage.rb +282 -0
- data/lib/middleman/features/cache_buster.rb +43 -0
- data/lib/middleman/features/default_helpers.rb +68 -0
- data/lib/middleman/features/livereload.rb +19 -0
- data/lib/middleman/features/minify_css.rb +9 -0
- data/lib/middleman/features/minify_javascript.rb +20 -0
- data/lib/middleman/features/minify_javascript/rack.rb +31 -0
- data/lib/middleman/features/relative_assets.rb +35 -0
- data/lib/middleman/features/slickmap.rb +118 -0
- data/lib/middleman/features/smush_pngs.rb +38 -0
- data/lib/middleman/features/ugly_haml.rb +7 -0
- data/lib/middleman/renderers.rb +26 -0
- data/lib/middleman/renderers/coffee.rb +28 -0
- data/lib/middleman/renderers/haml.rb +47 -0
- data/lib/middleman/renderers/sass.rb +67 -0
- data/lib/middleman/template/init.rbt +57 -0
- data/lib/middleman/template/views/index.html.haml +4 -0
- data/lib/middleman/template/views/layout.haml +11 -4
- data/lib/middleman/template/views/stylesheets/site.css.sass +27 -0
- data/lib/middleman/templater+dynamic_renderer.rb +26 -0
- data/middleman.gemspec +121 -107
- data/spec/builder_spec.rb +17 -16
- data/spec/fixtures/sample/init.rb +28 -2
- data/spec/fixtures/sample/public/images/blank.gif +0 -0
- data/spec/fixtures/sample/public/static.html +0 -0
- data/{vendor/sinatra-maruku/examples/public/javascripts/application.js → spec/fixtures/sample/public/stylesheets/auto-css.css} +0 -0
- data/spec/fixtures/sample/public/stylesheets/static.css +0 -0
- data/{vendor/sinatra-maruku/examples/public/stylesheets/print.css → spec/fixtures/sample/public/stylesheets/sub1/auto-css.css} +0 -0
- data/spec/fixtures/sample/public/stylesheets/sub1/sub2/auto-css.css +0 -0
- data/spec/fixtures/sample/views/_partial.haml +0 -0
- data/spec/fixtures/sample/views/asset_host.html.haml +1 -0
- data/spec/fixtures/sample/views/auto-css.html.haml +1 -0
- data/spec/fixtures/sample/views/auto-image-sizes.html.haml +1 -0
- data/spec/fixtures/sample/views/cache-buster.html.haml +2 -0
- data/spec/fixtures/sample/views/{index.haml → custom-layout.html.haml} +0 -0
- data/spec/fixtures/sample/views/custom.haml +5 -0
- data/spec/fixtures/sample/views/index.html.haml +1 -0
- data/spec/fixtures/sample/views/inline-css.html.haml +4 -0
- data/spec/fixtures/sample/views/{inline-js.haml → inline-js.html.haml} +0 -0
- data/spec/fixtures/sample/views/layout.haml +1 -1
- data/spec/fixtures/sample/views/{maruku.maruku → maruku.html.maruku} +0 -0
- data/spec/fixtures/sample/views/page-classes.html.haml +1 -0
- data/spec/fixtures/sample/views/services/{index.haml → index.html.haml} +0 -0
- data/spec/fixtures/sample/views/stylesheets/asset_host.css.sass +3 -0
- data/spec/fixtures/sample/views/stylesheets/relative_assets.css.sass +3 -0
- data/spec/fixtures/sample/views/stylesheets/site.css.sass +1 -0
- data/spec/fixtures/sample/views/stylesheets/site_scss.css.scss +1 -0
- data/spec/fixtures/sample/views/stylesheets/test_less.css.less +5 -0
- data/spec/helpers_spec.rb +43 -0
- data/spec/spec_helper.rb +3 -5
- metadata +298 -127
- data/lib/middleman/helpers.rb +0 -131
- data/lib/middleman/markaby.rb +0 -4
- data/lib/middleman/maruku.rb +0 -4
- data/lib/middleman/sprockets_ext.rb +0 -29
- data/lib/middleman/template/init.rb +0 -22
- data/lib/middleman/template/views/index.haml +0 -1
- data/lib/middleman/template/views/stylesheets/site.sass +0 -1
- data/spec/fixtures/sample/views/markaby.mab +0 -5
- data/spec/fixtures/sample/views/stylesheets/site.sass +0 -1
- data/spec/generator_spec.rb +0 -34
- data/vendor/rack-test/History.txt +0 -64
- data/vendor/rack-test/MIT-LICENSE.txt +0 -19
- data/vendor/rack-test/README.rdoc +0 -57
- data/vendor/rack-test/Rakefile +0 -62
- data/vendor/rack-test/lib/rack/mock_session.rb +0 -57
- data/vendor/rack-test/lib/rack/test.rb +0 -246
- data/vendor/rack-test/lib/rack/test/cookie_jar.rb +0 -169
- data/vendor/rack-test/lib/rack/test/methods.rb +0 -73
- data/vendor/rack-test/lib/rack/test/mock_digest_request.rb +0 -27
- data/vendor/rack-test/lib/rack/test/uploaded_file.rb +0 -36
- data/vendor/rack-test/lib/rack/test/utils.rb +0 -75
- data/vendor/rack-test/spec/fixtures/config.ru +0 -3
- data/vendor/rack-test/spec/fixtures/fake_app.rb +0 -109
- data/vendor/rack-test/spec/fixtures/foo.txt +0 -1
- data/vendor/rack-test/spec/rack/test/cookie_spec.rb +0 -176
- data/vendor/rack-test/spec/rack/test/digest_auth_spec.rb +0 -48
- data/vendor/rack-test/spec/rack/test/multipart_spec.rb +0 -85
- data/vendor/rack-test/spec/rack/test/utils_spec.rb +0 -44
- data/vendor/rack-test/spec/rack/test_spec.rb +0 -363
- data/vendor/rack-test/spec/rcov.opts +0 -1
- data/vendor/rack-test/spec/spec.opts +0 -1
- data/vendor/rack-test/spec/spec_helper.rb +0 -48
- data/vendor/sinatra-content-for/LICENSE +0 -22
- data/vendor/sinatra-content-for/README.rdoc +0 -49
- data/vendor/sinatra-content-for/Rakefile +0 -33
- data/vendor/sinatra-content-for/lib/sinatra/content_for.rb +0 -58
- data/vendor/sinatra-content-for/sinatra-content-for.gemspec +0 -34
- data/vendor/sinatra-content-for/test/content_for_test.rb +0 -156
- data/vendor/sinatra-markaby/CHANGES +0 -7
- data/vendor/sinatra-markaby/LICENSE +0 -20
- data/vendor/sinatra-markaby/README.rdoc +0 -33
- data/vendor/sinatra-markaby/Rakefile +0 -45
- data/vendor/sinatra-markaby/TODO +0 -3
- data/vendor/sinatra-markaby/VERSION.yml +0 -4
- data/vendor/sinatra-markaby/lib/sinatra/markaby.rb +0 -31
- data/vendor/sinatra-markaby/sinatra-markaby.gemspec +0 -49
- data/vendor/sinatra-markaby/test/sinatra_markaby_test.rb +0 -72
- data/vendor/sinatra-markaby/test/test_helper.rb +0 -19
- data/vendor/sinatra-markaby/test/views/hello.mab +0 -1
- data/vendor/sinatra-markaby/test/views/html.mab +0 -4
- data/vendor/sinatra-maruku/LICENSE +0 -22
- data/vendor/sinatra-maruku/README.markdown +0 -85
- data/vendor/sinatra-maruku/Rakefile +0 -34
- data/vendor/sinatra-maruku/VERSION.yml +0 -4
- data/vendor/sinatra-maruku/examples/app.rb +0 -8
- data/vendor/sinatra-maruku/examples/config.ru +0 -4
- data/vendor/sinatra-maruku/examples/mapp.rb +0 -15
- data/vendor/sinatra-maruku/examples/public/stylesheets/application.css +0 -23
- data/vendor/sinatra-maruku/examples/views/index.maruku +0 -32
- data/vendor/sinatra-maruku/examples/views/layout.maruku +0 -9
- data/vendor/sinatra-maruku/lib/sinatra/maruku.rb +0 -25
- data/vendor/sinatra-maruku/sinatra-maruku.gemspec +0 -70
- data/vendor/sinatra-maruku/test/sinatra_maruku_test.rb +0 -91
- data/vendor/sinatra-maruku/test/test_helper.rb +0 -21
- data/vendor/sinatra-maruku/test/views/hello.maruku +0 -1
- data/vendor/sinatra-maruku/test/views/layout2.maruku +0 -2
@@ -1 +0,0 @@
|
|
1
|
-
-x gems,spec
|
@@ -1 +0,0 @@
|
|
1
|
-
--color
|
@@ -1,48 +0,0 @@
|
|
1
|
-
require "rubygems"
|
2
|
-
require "spec"
|
3
|
-
|
4
|
-
gem "rack", "~> 1.0.0"
|
5
|
-
|
6
|
-
require File.expand_path(File.dirname(__FILE__) + "/../lib/rack/test")
|
7
|
-
require File.dirname(__FILE__) + "/fixtures/fake_app"
|
8
|
-
|
9
|
-
Spec::Runner.configure do |config|
|
10
|
-
config.include Rack::Test::Methods
|
11
|
-
|
12
|
-
def app
|
13
|
-
Rack::Lint.new(Rack::Test::FakeApp.new)
|
14
|
-
end
|
15
|
-
|
16
|
-
end
|
17
|
-
|
18
|
-
describe "any #verb methods", :shared => true do
|
19
|
-
it "requests the URL using VERB" do
|
20
|
-
send(verb, "/")
|
21
|
-
|
22
|
-
last_request.env["REQUEST_METHOD"].should == verb.upcase
|
23
|
-
last_response.should be_ok
|
24
|
-
end
|
25
|
-
|
26
|
-
it "uses the provided env" do
|
27
|
-
send(verb, "/", {}, { "User-Agent" => "Rack::Test" })
|
28
|
-
last_request.env["User-Agent"].should == "Rack::Test"
|
29
|
-
end
|
30
|
-
|
31
|
-
it "yields the response to a given block" do
|
32
|
-
yielded = false
|
33
|
-
|
34
|
-
send(verb, "/") do |response|
|
35
|
-
response.should be_ok
|
36
|
-
yielded = true
|
37
|
-
end
|
38
|
-
|
39
|
-
yielded.should be_true
|
40
|
-
end
|
41
|
-
|
42
|
-
context "for a XHR" do
|
43
|
-
it "sends XMLHttpRequest for the X-Requested-With header" do
|
44
|
-
send(verb, "/", {}, { :xhr => true })
|
45
|
-
last_request.env["X-Requested-With"].should == "XMLHttpRequest"
|
46
|
-
end
|
47
|
-
end
|
48
|
-
end
|
@@ -1,22 +0,0 @@
|
|
1
|
-
(The MIT License)
|
2
|
-
|
3
|
-
Copyright (c) 2008-2009 Nicolas Sanguinetti, entp.com
|
4
|
-
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
-
a copy of this software and associated documentation files (the
|
7
|
-
'Software'), to deal in the Software without restriction, including
|
8
|
-
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
-
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
-
permit persons to whom the Software is furnished to do so, subject to
|
11
|
-
the following conditions:
|
12
|
-
|
13
|
-
The above copyright notice and this permission notice shall be
|
14
|
-
included in all copies or substantial portions of the Software.
|
15
|
-
|
16
|
-
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
17
|
-
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
-
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
19
|
-
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
20
|
-
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
21
|
-
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
22
|
-
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
@@ -1,49 +0,0 @@
|
|
1
|
-
= ContentFor
|
2
|
-
|
3
|
-
Small extension for the Sinatra[http://sinatrarb.com] web framework
|
4
|
-
that allows you to use the following helpers in your views:
|
5
|
-
|
6
|
-
<% content_for :some_key do %>
|
7
|
-
<chunk of="html">...</chunk>
|
8
|
-
<% end %>
|
9
|
-
|
10
|
-
<% yield_content :some_key %>
|
11
|
-
|
12
|
-
This allows you to capture blocks inside views to be rendered later
|
13
|
-
in this request. For example, to populate different parts of your
|
14
|
-
layout from your view.
|
15
|
-
|
16
|
-
When using this with the Haml rendering engine, you should do the
|
17
|
-
following:
|
18
|
-
|
19
|
-
- content_for :some_key do
|
20
|
-
%chunk{ :of => "html" } ...
|
21
|
-
|
22
|
-
= yield_content :some_key
|
23
|
-
|
24
|
-
<b>Note</b> that with ERB <tt>yield_content</tt> is called <b>without</b>
|
25
|
-
an '=' block (<tt><%= %></tt>), but with Haml it uses <tt>= yield_content</tt>.
|
26
|
-
|
27
|
-
Using an '=' block in ERB will output the content twice for each block,
|
28
|
-
so if you have problems with that, make sure to check for this.
|
29
|
-
|
30
|
-
== Usage
|
31
|
-
|
32
|
-
If you're writing "classic" style apps, then requring
|
33
|
-
<tt>sinatra/content_for</tt> should be enough. If you're writing
|
34
|
-
"classy" apps, then you also need to call
|
35
|
-
<tt>helpers Sinatra::ContentFor</tt> in your app definition.
|
36
|
-
|
37
|
-
== And how is this useful?
|
38
|
-
|
39
|
-
For example, some of your views might need a few javascript tags and
|
40
|
-
stylesheets, but you don't want to force this files in all your pages.
|
41
|
-
Then you can put <tt><% yield_content :scripts_and_styles %></tt> on
|
42
|
-
your layout, inside the <head> tag, and each view can call
|
43
|
-
<tt>content_for</tt> setting the appropriate set of tags that should
|
44
|
-
be added to the layout.
|
45
|
-
|
46
|
-
== Credits
|
47
|
-
|
48
|
-
Code by foca[http://github.com/foca], inspired on the Ruby on Rails
|
49
|
-
helpers with the same name. Haml support by mattly[http://github.com/mattly].
|
@@ -1,33 +0,0 @@
|
|
1
|
-
require "rake/testtask"
|
2
|
-
|
3
|
-
begin
|
4
|
-
require "hanna/rdoctask"
|
5
|
-
rescue LoadError
|
6
|
-
require "rake/rdoctask"
|
7
|
-
end
|
8
|
-
|
9
|
-
begin
|
10
|
-
require "metric_fu"
|
11
|
-
rescue LoadError
|
12
|
-
end
|
13
|
-
|
14
|
-
begin
|
15
|
-
require "mg"
|
16
|
-
MG.new("sinatra-content-for.gemspec")
|
17
|
-
rescue LoadError
|
18
|
-
end
|
19
|
-
|
20
|
-
desc "Default: run all tests"
|
21
|
-
task :default => :test
|
22
|
-
|
23
|
-
desc "Run library tests"
|
24
|
-
Rake::TestTask.new do |t|
|
25
|
-
t.test_files = FileList['test/**/*_test.rb']
|
26
|
-
end
|
27
|
-
|
28
|
-
Rake::RDocTask.new do |rd|
|
29
|
-
rd.main = "README"
|
30
|
-
rd.title = "Documentation for ContentFor"
|
31
|
-
rd.rdoc_files.include("README.rdoc", "LICENSE", "lib/**/*.rb")
|
32
|
-
rd.rdoc_dir = "doc"
|
33
|
-
end
|
@@ -1,58 +0,0 @@
|
|
1
|
-
module Sinatra
|
2
|
-
module ContentFor
|
3
|
-
# Capture a block of content to be rendered later. For example:
|
4
|
-
#
|
5
|
-
# <% content_for :head do %>
|
6
|
-
# <script type="text/javascript" src="/foo.js"></script>
|
7
|
-
# <% end %>
|
8
|
-
#
|
9
|
-
# You can call +content_for+ multiple times with the same key
|
10
|
-
# (in the example +:head+), and when you render the blocks for
|
11
|
-
# that key all of them will be rendered, in the same order you
|
12
|
-
# captured them.
|
13
|
-
#
|
14
|
-
# Your blocks can also receive values, which are passed to them
|
15
|
-
# by <tt>yield_content</tt>
|
16
|
-
def content_for(key, &block)
|
17
|
-
content_blocks[key.to_sym] << block
|
18
|
-
end
|
19
|
-
|
20
|
-
# Render the captured blocks for a given key. For example:
|
21
|
-
#
|
22
|
-
# <head>
|
23
|
-
# <title>Example</title>
|
24
|
-
# <% yield_content :head %>
|
25
|
-
# </head>
|
26
|
-
#
|
27
|
-
# Would render everything you declared with <tt>content_for
|
28
|
-
# :head</tt> before closing the <tt><head></tt> tag.
|
29
|
-
#
|
30
|
-
# You can also pass values to the content blocks by passing them
|
31
|
-
# as arguments after the key:
|
32
|
-
#
|
33
|
-
# <% yield_content :head, 1, 2 %>
|
34
|
-
#
|
35
|
-
# Would pass <tt>1</tt> and <tt>2</tt> to all the blocks registered
|
36
|
-
# for <tt>:head</tt>.
|
37
|
-
#
|
38
|
-
# *NOTICE* that you call this without an <tt>=</tt> sign. IE,
|
39
|
-
# in a <tt><% %></tt> block, and not in a <tt><%= %></tt> block.
|
40
|
-
def yield_content(key, *args)
|
41
|
-
content_blocks[key.to_sym].map do |content|
|
42
|
-
if respond_to?(:block_is_haml?) && block_is_haml?(content)
|
43
|
-
capture_haml(*args, &content)
|
44
|
-
else
|
45
|
-
content.call(*args)
|
46
|
-
end
|
47
|
-
end.join
|
48
|
-
end
|
49
|
-
|
50
|
-
private
|
51
|
-
|
52
|
-
def content_blocks
|
53
|
-
@content_blocks ||= Hash.new {|h,k| h[k] = [] }
|
54
|
-
end
|
55
|
-
end
|
56
|
-
|
57
|
-
helpers ContentFor
|
58
|
-
end
|
@@ -1,34 +0,0 @@
|
|
1
|
-
Gem::Specification.new do |s|
|
2
|
-
s.name = "sinatra-content-for"
|
3
|
-
s.version = "0.2"
|
4
|
-
s.date = "2009-05-09"
|
5
|
-
|
6
|
-
s.description = "Small Sinatra extension to add a content_for helper similar to Rails'"
|
7
|
-
s.summary = "Small Sinatra extension to add a content_for helper similar to Rails'"
|
8
|
-
s.homepage = "http://sinatrarb.com"
|
9
|
-
|
10
|
-
s.authors = ["Nicolás Sanguinetti"]
|
11
|
-
s.email = "contacto@nicolassanguinetti.info"
|
12
|
-
|
13
|
-
s.require_paths = ["lib"]
|
14
|
-
s.rubyforge_project = "sinatra-ditties"
|
15
|
-
s.has_rdoc = true
|
16
|
-
s.rubygems_version = "1.3.1"
|
17
|
-
|
18
|
-
s.add_dependency "sinatra"
|
19
|
-
|
20
|
-
if s.respond_to?(:add_development_dependency)
|
21
|
-
s.add_development_dependency "contest"
|
22
|
-
s.add_development_dependency "sr-mg"
|
23
|
-
s.add_development_dependency "redgreen"
|
24
|
-
end
|
25
|
-
|
26
|
-
s.files = %w[
|
27
|
-
.gitignore
|
28
|
-
LICENSE
|
29
|
-
README.rdoc
|
30
|
-
sinatra-content-for.gemspec
|
31
|
-
lib/sinatra/content_for.rb
|
32
|
-
test/content_for_test.rb
|
33
|
-
]
|
34
|
-
end
|
@@ -1,156 +0,0 @@
|
|
1
|
-
ENV['RACK_ENV'] = 'test'
|
2
|
-
|
3
|
-
begin
|
4
|
-
require 'rack'
|
5
|
-
rescue LoadError
|
6
|
-
require 'rubygems'
|
7
|
-
require 'rack'
|
8
|
-
end
|
9
|
-
|
10
|
-
require 'contest'
|
11
|
-
require 'sinatra/test'
|
12
|
-
require 'haml'
|
13
|
-
|
14
|
-
begin
|
15
|
-
require 'redgreen'
|
16
|
-
rescue LoadError
|
17
|
-
end
|
18
|
-
|
19
|
-
require File.dirname(__FILE__) + '/../lib/sinatra/content_for'
|
20
|
-
|
21
|
-
Sinatra::Base.set :environment, :test
|
22
|
-
|
23
|
-
module Sinatra
|
24
|
-
class Base
|
25
|
-
set :environment, :test
|
26
|
-
helpers ContentFor
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
class Test::Unit::TestCase
|
31
|
-
include Sinatra::Test
|
32
|
-
|
33
|
-
class << self
|
34
|
-
alias_method :it, :test
|
35
|
-
end
|
36
|
-
|
37
|
-
def mock_app(base=Sinatra::Base, &block)
|
38
|
-
@app = Sinatra.new(base, &block)
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
class ContentForTest < Test::Unit::TestCase
|
43
|
-
context 'using erb' do
|
44
|
-
def erb_app(view)
|
45
|
-
mock_app {
|
46
|
-
layout { '<% yield_content :foo %>' }
|
47
|
-
get('/') { erb view }
|
48
|
-
}
|
49
|
-
end
|
50
|
-
|
51
|
-
it 'renders blocks declared with the same key you use when rendering' do
|
52
|
-
erb_app '<% content_for :foo do %>foo<% end %>'
|
53
|
-
|
54
|
-
get '/'
|
55
|
-
assert ok?
|
56
|
-
assert_equal 'foo', body
|
57
|
-
end
|
58
|
-
|
59
|
-
it 'does not render a block with a different key' do
|
60
|
-
erb_app '<% content_for :bar do %>bar<% end %>'
|
61
|
-
|
62
|
-
get '/'
|
63
|
-
assert ok?
|
64
|
-
assert_equal '', body
|
65
|
-
end
|
66
|
-
|
67
|
-
it 'renders multiple blocks with the same key' do
|
68
|
-
erb_app <<-erb_snippet
|
69
|
-
<% content_for :foo do %>foo<% end %>
|
70
|
-
<% content_for :foo do %>bar<% end %>
|
71
|
-
<% content_for :baz do %>WON'T RENDER ME<% end %>
|
72
|
-
<% content_for :foo do %>baz<% end %>
|
73
|
-
erb_snippet
|
74
|
-
|
75
|
-
get '/'
|
76
|
-
assert ok?
|
77
|
-
assert_equal 'foobarbaz', body
|
78
|
-
end
|
79
|
-
|
80
|
-
it 'passes values to the blocks' do
|
81
|
-
mock_app {
|
82
|
-
layout { '<% yield_content :foo, 1, 2 %>' }
|
83
|
-
get('/') { erb '<% content_for :foo do |a, b| %><i><%= a %></i> <%= b %><% end %>' }
|
84
|
-
}
|
85
|
-
|
86
|
-
get '/'
|
87
|
-
assert ok?
|
88
|
-
assert_equal '<i>1</i> 2', body
|
89
|
-
end
|
90
|
-
end
|
91
|
-
|
92
|
-
context 'with haml' do
|
93
|
-
def haml_app(view)
|
94
|
-
mock_app {
|
95
|
-
layout { '= yield_content :foo' }
|
96
|
-
get('/') { haml view }
|
97
|
-
}
|
98
|
-
end
|
99
|
-
|
100
|
-
it 'renders blocks declared with the same key you use when rendering' do
|
101
|
-
haml_app <<-haml_end
|
102
|
-
- content_for :foo do
|
103
|
-
foo
|
104
|
-
haml_end
|
105
|
-
|
106
|
-
get '/'
|
107
|
-
assert ok?
|
108
|
-
assert_equal "foo\n", body
|
109
|
-
end
|
110
|
-
|
111
|
-
it 'does not render a block with a different key' do
|
112
|
-
haml_app <<-haml_end
|
113
|
-
- content_for :bar do
|
114
|
-
bar
|
115
|
-
haml_end
|
116
|
-
|
117
|
-
get '/'
|
118
|
-
assert ok?
|
119
|
-
assert_equal "\n", body
|
120
|
-
end
|
121
|
-
|
122
|
-
it 'renders multiple blocks with the same key' do
|
123
|
-
haml_app <<-haml_end
|
124
|
-
- content_for :foo do
|
125
|
-
foo
|
126
|
-
- content_for :foo do
|
127
|
-
bar
|
128
|
-
- content_for :baz do
|
129
|
-
WON'T RENDER ME
|
130
|
-
- content_for :foo do
|
131
|
-
baz
|
132
|
-
haml_end
|
133
|
-
|
134
|
-
get '/'
|
135
|
-
assert ok?
|
136
|
-
assert_equal "foo\nbar\nbaz\n", body
|
137
|
-
end
|
138
|
-
|
139
|
-
it 'passes values to the blocks' do
|
140
|
-
mock_app {
|
141
|
-
layout { '= yield_content :foo, 1, 2' }
|
142
|
-
get('/') {
|
143
|
-
haml <<-haml_end
|
144
|
-
- content_for :foo do |a, b|
|
145
|
-
%i= a
|
146
|
-
=b
|
147
|
-
haml_end
|
148
|
-
}
|
149
|
-
}
|
150
|
-
|
151
|
-
get '/'
|
152
|
-
assert ok?
|
153
|
-
assert_equal "<i>1</i>\n2\n", body
|
154
|
-
end
|
155
|
-
end
|
156
|
-
end
|
@@ -1,20 +0,0 @@
|
|
1
|
-
Copyright (c) 2009 unwwwired.net
|
2
|
-
|
3
|
-
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
-
a copy of this software and associated documentation files (the
|
5
|
-
"Software"), to deal in the Software without restriction, including
|
6
|
-
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
-
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
-
permit persons to whom the Software is furnished to do so, subject to
|
9
|
-
the following conditions:
|
10
|
-
|
11
|
-
The above copyright notice and this permission notice shall be
|
12
|
-
included in all copies or substantial portions of the Software.
|
13
|
-
|
14
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
-
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
-
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
-
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
-
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
-
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
-
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
@@ -1,33 +0,0 @@
|
|
1
|
-
= sinatra-markaby
|
2
|
-
|
3
|
-
sinatra-markaby is an extension for sinatra to enable rendering of html files
|
4
|
-
using markaby templates.
|
5
|
-
|
6
|
-
== Installation
|
7
|
-
|
8
|
-
sudo gem install sbfaulkner-sinatra-markaby -s http://gems.github.com
|
9
|
-
|
10
|
-
== Example
|
11
|
-
|
12
|
-
require 'rubygems'
|
13
|
-
require 'sinatra'
|
14
|
-
require 'sinatra/markaby'
|
15
|
-
|
16
|
-
get '/' do
|
17
|
-
markaby :template
|
18
|
-
end
|
19
|
-
|
20
|
-
__END__
|
21
|
-
|
22
|
-
@@ template
|
23
|
-
mab.html do
|
24
|
-
head { title "Hello world" }
|
25
|
-
body do
|
26
|
-
p "Hello world!!!!!"
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
== Legal
|
31
|
-
|
32
|
-
Author:: S. Brent Faulkner <brentf@unwwwired.net>
|
33
|
-
License:: Copyright (c) 2009 unwwwired.net, released under the MIT license
|