public
Description: Merb More: The Full Stack. Take what you need; leave what you don't.
Homepage: http://www.merbivore.com
Clone URL: git://github.com/wycats/merb-more.git
Read Haml configuration information from config/plugins.yml.

Signed-off-by: Michael D. Ivey <ivey@gweezlebur.com>
nex3 (author)
Tue Feb 05 18:35:07 -0800 2008
ivey (committer)
Tue Feb 12 21:34:15 -0800 2008
commit  160cf60a59af602eed693f7f0a526d18dbf2d6cc
tree    389ac6e2687ba2ec11186d9aa3aa1d96131d555e
parent  98b1750acd4e4e7cfbb07ae80f01660156022138
...
3
4
5
6
 
 
 
 
 
7
8
9
...
19
20
21
22
23
 
...
3
4
5
 
6
7
8
9
10
11
12
13
...
23
24
25
 
26
27
0
@@ -3,7 +3,11 @@ module Merb::Template
0
   class Haml
0
     def self.compile_template(path, name, mod)
0
       path = File.expand_path(path)
0
- template = ::Haml::Engine.new(File.read(path), :filename => path)
0
+ config = (Merb::Plugins.config[:haml] || {}).inject({}) do |c, (k, v)|
0
+ c[k.to_sym] = v
0
+ c
0
+ end.merge :filename => path
0
+ template = ::Haml::Engine.new(File.read(path), config)
0
       template.def_method(mod, name)
0
       name
0
     end
0
@@ -19,4 +23,4 @@ module Merb::Template
0
     end
0
     Merb::Template.register_extensions(self, %w[haml])
0
   end
0
-end
0
\ No newline at end of file
0
+end
...
11
12
13
 
 
 
 
 
 
14
15
16
17
18
19
20
 
...
11
12
13
14
15
16
17
18
19
20
21
22
23
24
 
25
26
0
@@ -11,9 +11,15 @@ class PartialHaml < HamlController
0
   end
0
 end
0
 
0
+class HamlConfig < HamlController
0
+ def index
0
+ render
0
+ end
0
+end
0
+
0
 class PartialIvars < HamlController
0
   def index
0
     @var1 = "Partial"
0
     render
0
   end
0
-end
0
\ No newline at end of file
0
+end
...
10
11
12
 
 
 
 
 
13
14
15
16
17
18
19
 
...
10
11
12
13
14
15
16
17
18
19
20
21
22
 
23
24
0
@@ -10,9 +10,14 @@ describe "HAML" do
0
     c = dispatch_to(PartialHaml, :index)
0
     c.body.should == ::Haml::Engine.new("#foo\n %p Partial").render
0
   end
0
+
0
+ it "should use the haml configuration in config/plugins.yml" do
0
+ c = dispatch_to(HamlConfig, :index)
0
+ c.body.should == ::Haml::Engine.new("#foo\n %foo", :autoclose => ["foo"]).render
0
+ end
0
   
0
   it "should be able to have ivars defined in both the controller and the parent template" do
0
     c = dispatch_to(PartialIvars, :index)
0
     c.body.should == ::Haml::Engine.new("#foo\n %p Partial HAML").render
0
   end
0
-end
0
\ No newline at end of file
0
+end
...
2
3
4
 
 
 
5
6
7
...
11
12
13
14
15
 
...
2
3
4
5
6
7
8
9
10
...
14
15
16
 
17
18
0
@@ -2,6 +2,9 @@ $TESTING=true
0
 $:.unshift File.join(File.dirname(__FILE__), '..', 'lib')
0
 require "rubygems"
0
 require "merb-core"
0
+
0
+Merb::Plugins.config[:haml] = {"autoclose" => ["foo"]}
0
+
0
 require "merb-haml"
0
 require File.dirname(__FILE__) / "controllers" / "haml"
0
 
0
@@ -11,4 +14,4 @@ require "merb-core/test/fake_request"
0
 require "merb-core/test/request_helper"
0
 Spec::Runner.configure do |config|
0
   config.include Merb::Test::RequestHelper
0
-end
0
\ No newline at end of file
0
+end

Comments

    No one has commented yet.