mirror of
https://github.com/sinatra/sinatra
synced 2023-03-27 23:18:01 -04:00
Support capture and content_for with Hamlit
This commit is contained in:
parent
04a02ac2b7
commit
78d48cdd08
15 changed files with 40 additions and 6 deletions
|
@ -16,8 +16,10 @@ group :development, :test do
|
|||
end
|
||||
|
||||
platform :jruby, :ruby do
|
||||
gem 'slim', '2.1.0'
|
||||
gem 'hamlit'
|
||||
gem 'hamlit-block', '>= 0.7.1'
|
||||
gem 'liquid', '~> 2.6.x'
|
||||
gem 'slim'
|
||||
end
|
||||
|
||||
platform :ruby do
|
||||
|
|
|
@ -29,9 +29,10 @@ module Sinatra
|
|||
erb? && Tilt[:erb] == Tilt::ErubisTemplate
|
||||
end
|
||||
|
||||
# @return [Boolean] Returns true if current engine is `:haml`.
|
||||
# @return [Boolean] Returns true if current engine is `:haml` and
|
||||
# `Tilt[:haml]` is set to `Tilt::HamlTemplate`.
|
||||
def haml?
|
||||
@current_engine == :haml
|
||||
@current_engine == :haml && Tilt[:haml] == Tilt::HamlTemplate
|
||||
end
|
||||
|
||||
# @return [Boolean] Returns true if current engine is `:sass`.
|
||||
|
|
|
@ -240,8 +240,8 @@ module Sinatra
|
|||
:css => [:less, :sass, :scss],
|
||||
:xml => [:builder, :nokogiri],
|
||||
:js => [:coffee],
|
||||
:html => [:erb, :erubi, :erubis, :haml, :slim, :liquid, :radius, :mab,
|
||||
:markdown, :textile, :rdoc],
|
||||
:html => [:erb, :erubi, :erubis, :haml, :halmit, :slim, :liquid, :radius,
|
||||
:mab, :markdown, :textile, :rdoc],
|
||||
:all => (Sinatra::Templates.instance_methods.map(&:to_sym) +
|
||||
[:mab] - [:find_template, :markaby]),
|
||||
:json => [:yajl],
|
||||
|
|
|
@ -23,6 +23,9 @@ describe Sinatra::Capture do
|
|||
if engine == :erubi || engine == :erubis
|
||||
lang = :erb
|
||||
end
|
||||
if engine == :hamlit
|
||||
lang = :haml
|
||||
end
|
||||
require "#{engine}"
|
||||
|
||||
it "captures content" do
|
||||
|
@ -35,6 +38,7 @@ describe Sinatra::Capture do
|
|||
end
|
||||
|
||||
describe('haml') { it_behaves_like "a template language", :haml }
|
||||
describe('hamlit') { it_behaves_like "a template language", :hamlit }
|
||||
describe('slim') { it_behaves_like "a template language", :slim }
|
||||
describe('erubi') { it_behaves_like "a template language", :erubi }
|
||||
describe('erubis') { it_behaves_like "a template language", :erubis }
|
||||
|
|
2
sinatra-contrib/spec/content_for/different_key.hamlit
Normal file
2
sinatra-contrib/spec/content_for/different_key.hamlit
Normal file
|
@ -0,0 +1,2 @@
|
|||
- content_for :bar do
|
||||
bar
|
2
sinatra-contrib/spec/content_for/footer.hamlit
Normal file
2
sinatra-contrib/spec/content_for/footer.hamlit
Normal file
|
@ -0,0 +1,2 @@
|
|||
- if content_for? :foo
|
||||
!= yield_content :foo
|
1
sinatra-contrib/spec/content_for/layout.hamlit
Normal file
1
sinatra-contrib/spec/content_for/layout.hamlit
Normal file
|
@ -0,0 +1 @@
|
|||
= yield_content :foo
|
8
sinatra-contrib/spec/content_for/multiple_blocks.hamlit
Normal file
8
sinatra-contrib/spec/content_for/multiple_blocks.hamlit
Normal file
|
@ -0,0 +1,8 @@
|
|||
- content_for :foo do
|
||||
foo
|
||||
- content_for :foo do
|
||||
bar
|
||||
- content_for :baz do
|
||||
WON'T RENDER ME
|
||||
- content_for :foo do
|
||||
baz
|
3
sinatra-contrib/spec/content_for/multiple_yields.hamlit
Normal file
3
sinatra-contrib/spec/content_for/multiple_yields.hamlit
Normal file
|
@ -0,0 +1,3 @@
|
|||
= yield_content :foo
|
||||
= yield_content :foo
|
||||
= yield_content :foo
|
1
sinatra-contrib/spec/content_for/parameter_value.hamlit
Normal file
1
sinatra-contrib/spec/content_for/parameter_value.hamlit
Normal file
|
@ -0,0 +1 @@
|
|||
- content_for :foo, 'foo'
|
1
sinatra-contrib/spec/content_for/passes_values.hamlit
Normal file
1
sinatra-contrib/spec/content_for/passes_values.hamlit
Normal file
|
@ -0,0 +1 @@
|
|||
!= yield_content :foo, 1, 2
|
2
sinatra-contrib/spec/content_for/same_key.hamlit
Normal file
2
sinatra-contrib/spec/content_for/same_key.hamlit
Normal file
|
@ -0,0 +1,2 @@
|
|||
- content_for :foo do
|
||||
foo
|
3
sinatra-contrib/spec/content_for/takes_values.hamlit
Normal file
3
sinatra-contrib/spec/content_for/takes_values.hamlit
Normal file
|
@ -0,0 +1,3 @@
|
|||
- content_for :foo do |a, b|
|
||||
%i= a
|
||||
=b
|
2
sinatra-contrib/spec/content_for/yield_block.hamlit
Normal file
2
sinatra-contrib/spec/content_for/yield_block.hamlit
Normal file
|
@ -0,0 +1,2 @@
|
|||
!= yield_content :foo do
|
||||
baz
|
|
@ -9,6 +9,8 @@ describe Sinatra::ContentFor do
|
|||
end
|
||||
|
||||
Tilt.prefer Tilt::ERBTemplate
|
||||
require 'hamlit/block'
|
||||
Tilt.register Tilt::HamlTemplate, :haml
|
||||
|
||||
extend Forwardable
|
||||
def_delegators :subject, :content_for, :clear_content_for, :yield_content
|
||||
|
@ -89,7 +91,7 @@ describe Sinatra::ContentFor do
|
|||
end
|
||||
|
||||
# TODO: liquid radius markaby builder nokogiri
|
||||
engines = %w[erb erubi erubis haml slim]
|
||||
engines = %w[erb erubi erubis haml hamlit slim]
|
||||
|
||||
engines.each do |inner|
|
||||
describe inner.capitalize do
|
||||
|
|
Loading…
Reference in a new issue