merb-haml 0.9.3 → 0.9.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/Rakefile +35 -22
- data/lib/generators/controller.rb +4 -0
- data/lib/generators/layout.rb +4 -0
- data/lib/generators/resource_controller.rb +12 -0
- data/lib/generators/templates/controller/app/views/%file_name%/index.html.haml +1 -0
- data/lib/generators/templates/layout/app/views/layout/%file_name%.html.haml +9 -0
- data/lib/generators/templates/resource_controller/activerecord/app/views/%file_name%/edit.html.haml +5 -0
- data/lib/generators/templates/resource_controller/activerecord/app/views/%file_name%/index.html.haml +5 -0
- data/lib/generators/templates/resource_controller/activerecord/app/views/%file_name%/new.html.haml +5 -0
- data/lib/generators/templates/resource_controller/activerecord/app/views/%file_name%/show.html.haml +5 -0
- data/lib/generators/templates/resource_controller/datamapper/app/views/%file_name%/edit.html.haml +22 -0
- data/lib/generators/templates/resource_controller/datamapper/app/views/%file_name%/index.html.haml +26 -0
- data/lib/generators/templates/resource_controller/datamapper/app/views/%file_name%/new.html.haml +20 -0
- data/lib/generators/templates/resource_controller/datamapper/app/views/%file_name%/show.html.haml +16 -0
- data/lib/generators/templates/resource_controller/none/app/views/%file_name%/edit.html.haml +5 -0
- data/lib/generators/templates/resource_controller/none/app/views/%file_name%/index.html.haml +5 -0
- data/lib/generators/templates/resource_controller/none/app/views/%file_name%/new.html.haml +5 -0
- data/lib/generators/templates/resource_controller/none/app/views/%file_name%/show.html.haml +5 -0
- data/lib/generators/templates/resource_controller/sequel/app/views/%file_name%/edit.html.haml +5 -0
- data/lib/generators/templates/resource_controller/sequel/app/views/%file_name%/index.html.haml +5 -0
- data/lib/generators/templates/resource_controller/sequel/app/views/%file_name%/new.html.haml +5 -0
- data/lib/generators/templates/resource_controller/sequel/app/views/%file_name%/show.html.haml +5 -0
- data/lib/merb-haml.rb +6 -0
- data/lib/merb-haml/template.rb +4 -4
- data/spec/haml_spec.rb +1 -1
- metadata +57 -7
data/Rakefile
CHANGED
|
@@ -1,29 +1,43 @@
|
|
|
1
1
|
require 'rubygems'
|
|
2
2
|
require 'rake/gempackagetask'
|
|
3
|
+
require "extlib"
|
|
4
|
+
require 'merb-core/tasks/merb_rake_helper'
|
|
5
|
+
require "spec/rake/spectask"
|
|
3
6
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
7
|
+
##############################################################################
|
|
8
|
+
# Package && release
|
|
9
|
+
##############################################################################
|
|
10
|
+
RUBY_FORGE_PROJECT = "merb"
|
|
11
|
+
PROJECT_URL = "http://merbivore.com"
|
|
12
|
+
PROJECT_SUMMARY = "Merb plugin that provides HAML support"
|
|
13
|
+
PROJECT_DESCRIPTION = PROJECT_SUMMARY
|
|
14
|
+
|
|
15
|
+
GEM_AUTHOR = "Yehuda Katz"
|
|
16
|
+
GEM_EMAIL = "ykatz@engineyard.com"
|
|
17
|
+
|
|
18
|
+
GEM_NAME = "merb-haml"
|
|
19
|
+
PKG_BUILD = ENV['PKG_BUILD'] ? '.' + ENV['PKG_BUILD'] : ''
|
|
20
|
+
GEM_VERSION = (Merb::MORE_VERSION rescue "0.9.4") + PKG_BUILD
|
|
21
|
+
|
|
22
|
+
RELEASE_NAME = "REL #{GEM_VERSION}"
|
|
23
|
+
|
|
24
|
+
require "extlib/tasks/release"
|
|
11
25
|
|
|
12
26
|
spec = Gem::Specification.new do |s|
|
|
13
|
-
s.
|
|
14
|
-
s.
|
|
27
|
+
s.rubyforge_project = RUBY_FORGE_PROJECT
|
|
28
|
+
s.name = GEM_NAME
|
|
29
|
+
s.version = GEM_VERSION
|
|
15
30
|
s.platform = Gem::Platform::RUBY
|
|
16
31
|
s.has_rdoc = true
|
|
17
32
|
s.extra_rdoc_files = ["README", "LICENSE", 'TODO']
|
|
18
|
-
s.summary =
|
|
19
|
-
s.description =
|
|
20
|
-
s.author =
|
|
21
|
-
s.email =
|
|
22
|
-
s.homepage =
|
|
23
|
-
s.add_dependency('merb-core', '>= 0.9.
|
|
24
|
-
s.add_dependency('haml', '>= 1.8.2')
|
|
33
|
+
s.summary = PROJECT_SUMMARY
|
|
34
|
+
s.description = PROJECT_DESCRIPTION
|
|
35
|
+
s.author = GEM_AUTHOR
|
|
36
|
+
s.email = GEM_EMAIL
|
|
37
|
+
s.homepage = PROJECT_URL
|
|
38
|
+
s.add_dependency('merb-core', '>= 0.9.4')
|
|
39
|
+
s.add_dependency('haml', '>= 1.8.2')
|
|
25
40
|
s.require_path = 'lib'
|
|
26
|
-
s.autorequire = PLUGIN
|
|
27
41
|
s.files = %w(LICENSE README Rakefile TODO) + Dir.glob("{lib,spec}/**/*")
|
|
28
42
|
end
|
|
29
43
|
|
|
@@ -31,17 +45,16 @@ Rake::GemPackageTask.new(spec) do |pkg|
|
|
|
31
45
|
pkg.gem_spec = spec
|
|
32
46
|
end
|
|
33
47
|
|
|
34
|
-
|
|
35
|
-
|
|
48
|
+
desc "Install the gem"
|
|
36
49
|
task :install => [:package] do
|
|
37
|
-
sh %{sudo gem install #{install_home} pkg/#{
|
|
50
|
+
sh %{#{sudo} gem install #{install_home} pkg/#{GEM_NAME}-#{GEM_VERSION} --no-update-sources}
|
|
38
51
|
end
|
|
39
52
|
|
|
40
53
|
namespace :jruby do
|
|
41
54
|
|
|
42
55
|
desc "Run :package and install the resulting .gem with jruby"
|
|
43
56
|
task :install => :package do
|
|
44
|
-
sh %{#{
|
|
57
|
+
sh %{#{sudo} jruby -S gem install #{install_home} pkg/#{GEM_NAME}-#{GEM_VERSION}.gem --no-rdoc --no-ri}
|
|
45
58
|
end
|
|
46
|
-
|
|
59
|
+
|
|
47
60
|
end
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
[:activerecord, :datamapper, :sequel, :none].each do |orm|
|
|
2
|
+
|
|
3
|
+
[:show, :index, :edit, :new].each do |view|
|
|
4
|
+
|
|
5
|
+
Merb::Generators::ResourceControllerGenerator.template "view_#{view}_haml", :orm => orm, :template_engine => :haml do
|
|
6
|
+
source(File.dirname(__FILE__), "templates/resource_controller/#{orm}/app/views/%file_name%/#{view}.html.haml")
|
|
7
|
+
destination("app/views", base_path, "#{file_name}/#{view}.html.haml")
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
end
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
You're in index of the <%= class_name %> controller.
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
!!! Strict
|
|
2
|
+
%html{ html_attrs("en_us") }
|
|
3
|
+
%head
|
|
4
|
+
%title
|
|
5
|
+
Fresh Merb App
|
|
6
|
+
%meta{ :content => "text/html; charset=utf-8", "http-equiv" => "content-type" }/
|
|
7
|
+
%link{ :href => "/stylesheets/master.css", :rel => "stylesheet", :media => "screen", :type => "text/css", :charset => "utf-8" }/
|
|
8
|
+
%body
|
|
9
|
+
= catch_content :for_layout
|
data/lib/generators/templates/resource_controller/datamapper/app/views/%file_name%/edit.html.haml
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
%h1
|
|
2
|
+
<%= class_name %> controller, edit action
|
|
3
|
+
%p
|
|
4
|
+
Edit this file in
|
|
5
|
+
%tt
|
|
6
|
+
app/views/<%= file_name %>/edit.html.erb
|
|
7
|
+
= error_messages_for :<%= singular_model %>
|
|
8
|
+
|
|
9
|
+
- form_for(@<%= singular_model %>, :action => url(:<%= singular_model %>, @<%= singular_model %>)) do
|
|
10
|
+
<% for property in properties.select{|p| !p.key?} -%>
|
|
11
|
+
%p
|
|
12
|
+
%b
|
|
13
|
+
<%= DataMapper::Inflection.humanize(property.field) %>
|
|
14
|
+
%br/
|
|
15
|
+
= <%= field_from_type(property.type) %> :<%= property.getter %>
|
|
16
|
+
<% end -%>
|
|
17
|
+
%p
|
|
18
|
+
= submit_button "Update"
|
|
19
|
+
|
|
20
|
+
= link_to 'Show', url(:<%= singular_model %>, @<%= singular_model %>)
|
|
21
|
+
|
|
|
22
|
+
= link_to 'Back', url(:<%= plural_model %>)
|
data/lib/generators/templates/resource_controller/datamapper/app/views/%file_name%/index.html.haml
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
%h1
|
|
2
|
+
<%= class_name %> controller, index action
|
|
3
|
+
%p
|
|
4
|
+
Edit this file in
|
|
5
|
+
%tt
|
|
6
|
+
app/views/<%= file_name %>/index.html.erb
|
|
7
|
+
%table
|
|
8
|
+
%tr
|
|
9
|
+
<% for property in properties.reject{|p| p.lazy?} -%>
|
|
10
|
+
%th
|
|
11
|
+
<%= DataMapper::Inflection.humanize(property.field) %>
|
|
12
|
+
<% end -%>
|
|
13
|
+
- for <%= singular_model %> in @<%= plural_model %>
|
|
14
|
+
%tr
|
|
15
|
+
<% for property in properties.reject{|p| p.lazy?} -%>
|
|
16
|
+
%td
|
|
17
|
+
=h <%= singular_model %>.<%= property.getter %>
|
|
18
|
+
<% end -%>
|
|
19
|
+
%td
|
|
20
|
+
= link_to 'Show', url(:<%= singular_model %>, <%= singular_model %>)
|
|
21
|
+
%td
|
|
22
|
+
= link_to 'Edit', url(:edit_<%= singular_model %>, <%= singular_model %>)
|
|
23
|
+
%td
|
|
24
|
+
= delete_button :<%= singular_model %>, <%= singular_model %>
|
|
25
|
+
|
|
26
|
+
= link_to 'New', url(:new_<%= singular_model %>)
|
data/lib/generators/templates/resource_controller/datamapper/app/views/%file_name%/new.html.haml
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
%h1 <%= class_name %> controller, new action
|
|
2
|
+
|
|
3
|
+
%p
|
|
4
|
+
Edit this file in
|
|
5
|
+
%tt app/views/<%= file_name %>/new.html.erb
|
|
6
|
+
|
|
7
|
+
= error_messages_for :<%= singular_model %>
|
|
8
|
+
|
|
9
|
+
- form_for(@<%= singular_model %>, :action => url(:<%= plural_model %>) ) do |f|
|
|
10
|
+
<% for property in properties.select{|p| !p.key?} -%>
|
|
11
|
+
%p
|
|
12
|
+
%b
|
|
13
|
+
<%= DataMapper::Inflection.humanize(property.field) %></b>
|
|
14
|
+
= <%= field_from_type(property.type) %> :<%= property.getter %>
|
|
15
|
+
|
|
16
|
+
<% end -%>
|
|
17
|
+
%p
|
|
18
|
+
= submit_button "Create"
|
|
19
|
+
|
|
20
|
+
= link_to 'Back', url(:<%= plural_model %>)
|
data/lib/generators/templates/resource_controller/datamapper/app/views/%file_name%/show.html.haml
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
%h1
|
|
2
|
+
<%= class_name %> controller, show action
|
|
3
|
+
%p
|
|
4
|
+
Edit this file in
|
|
5
|
+
%tt
|
|
6
|
+
app/views/<%= file_name %>/show.html.erb
|
|
7
|
+
<% for property in properties -%>
|
|
8
|
+
%p
|
|
9
|
+
%b
|
|
10
|
+
<%= DataMapper::Inflection.humanize(property.field) %>:
|
|
11
|
+
=h @<%= singular_model %>.<%= property.getter %>
|
|
12
|
+
<% end -%>
|
|
13
|
+
|
|
14
|
+
= link_to 'Edit', url(:edit_<%= singular_model %>, @<%= singular_model %>)
|
|
15
|
+
|
|
|
16
|
+
= link_to 'Back', url(:<%= plural_model %>)
|
data/lib/merb-haml.rb
CHANGED
|
@@ -17,4 +17,10 @@ if defined?(Merb::Plugins)
|
|
|
17
17
|
self
|
|
18
18
|
end
|
|
19
19
|
end
|
|
20
|
+
|
|
21
|
+
generators = File.join(File.dirname(__FILE__), 'generators')
|
|
22
|
+
Merb.add_generators generators / "resource_controller"
|
|
23
|
+
Merb.add_generators generators / "controller"
|
|
24
|
+
Merb.add_generators generators / "layout"
|
|
25
|
+
|
|
20
26
|
end
|
data/lib/merb-haml/template.rb
CHANGED
|
@@ -9,13 +9,13 @@ module Merb::Template
|
|
|
9
9
|
# name<~to_s>:: The name of the template method.
|
|
10
10
|
# mod<Class, Module>::
|
|
11
11
|
# The class or module wherein this method should be defined.
|
|
12
|
-
def self.compile_template(
|
|
13
|
-
path = File.expand_path(path)
|
|
14
|
-
config = (Merb::
|
|
12
|
+
def self.compile_template(io, name, mod)
|
|
13
|
+
path = File.expand_path(io.path)
|
|
14
|
+
config = (Merb::Plugins.config[:haml] || {}).inject({}) do |c, (k, v)|
|
|
15
15
|
c[k.to_sym] = v
|
|
16
16
|
c
|
|
17
17
|
end.merge :filename => path
|
|
18
|
-
template = ::Haml::Engine.new(
|
|
18
|
+
template = ::Haml::Engine.new(io.read, config)
|
|
19
19
|
template.def_method(mod, name)
|
|
20
20
|
name
|
|
21
21
|
end
|
data/spec/haml_spec.rb
CHANGED
|
@@ -11,7 +11,7 @@ describe "HAML" do
|
|
|
11
11
|
c.body.should == ::Haml::Engine.new("#foo\n %p Partial").render
|
|
12
12
|
end
|
|
13
13
|
|
|
14
|
-
it "should use the haml configuration in Merb::
|
|
14
|
+
it "should use the haml configuration in Merb::Plugins.config" do
|
|
15
15
|
c = dispatch_to(HamlConfig, :index)
|
|
16
16
|
c.body.should == ::Haml::Engine.new("#foo\n %foo", :autoclose => ["foo"]).render
|
|
17
17
|
end
|
metadata
CHANGED
|
@@ -1,28 +1,30 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: merb-haml
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.9.
|
|
4
|
+
version: 0.9.4
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Yehuda Katz
|
|
8
|
-
autorequire:
|
|
8
|
+
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
11
|
|
|
12
|
-
date: 2008-
|
|
12
|
+
date: 2008-08-13 00:00:00 +03:00
|
|
13
13
|
default_executable:
|
|
14
14
|
dependencies:
|
|
15
15
|
- !ruby/object:Gem::Dependency
|
|
16
16
|
name: merb-core
|
|
17
|
+
type: :runtime
|
|
17
18
|
version_requirement:
|
|
18
19
|
version_requirements: !ruby/object:Gem::Requirement
|
|
19
20
|
requirements:
|
|
20
21
|
- - ">="
|
|
21
22
|
- !ruby/object:Gem::Version
|
|
22
|
-
version: 0.9.
|
|
23
|
+
version: 0.9.4
|
|
23
24
|
version:
|
|
24
25
|
- !ruby/object:Gem::Dependency
|
|
25
26
|
name: haml
|
|
27
|
+
type: :runtime
|
|
26
28
|
version_requirement:
|
|
27
29
|
version_requirements: !ruby/object:Gem::Requirement
|
|
28
30
|
requirements:
|
|
@@ -45,6 +47,54 @@ files:
|
|
|
45
47
|
- README
|
|
46
48
|
- Rakefile
|
|
47
49
|
- TODO
|
|
50
|
+
- lib/generators
|
|
51
|
+
- lib/generators/controller.rb
|
|
52
|
+
- lib/generators/layout.rb
|
|
53
|
+
- lib/generators/resource_controller.rb
|
|
54
|
+
- lib/generators/templates
|
|
55
|
+
- lib/generators/templates/controller
|
|
56
|
+
- lib/generators/templates/controller/app
|
|
57
|
+
- lib/generators/templates/controller/app/views
|
|
58
|
+
- lib/generators/templates/controller/app/views/%file_name%
|
|
59
|
+
- lib/generators/templates/controller/app/views/%file_name%/index.html.haml
|
|
60
|
+
- lib/generators/templates/layout
|
|
61
|
+
- lib/generators/templates/layout/app
|
|
62
|
+
- lib/generators/templates/layout/app/views
|
|
63
|
+
- lib/generators/templates/layout/app/views/layout
|
|
64
|
+
- lib/generators/templates/layout/app/views/layout/%file_name%.html.haml
|
|
65
|
+
- lib/generators/templates/resource_controller
|
|
66
|
+
- lib/generators/templates/resource_controller/activerecord
|
|
67
|
+
- lib/generators/templates/resource_controller/activerecord/app
|
|
68
|
+
- lib/generators/templates/resource_controller/activerecord/app/views
|
|
69
|
+
- lib/generators/templates/resource_controller/activerecord/app/views/%file_name%
|
|
70
|
+
- lib/generators/templates/resource_controller/activerecord/app/views/%file_name%/edit.html.haml
|
|
71
|
+
- lib/generators/templates/resource_controller/activerecord/app/views/%file_name%/index.html.haml
|
|
72
|
+
- lib/generators/templates/resource_controller/activerecord/app/views/%file_name%/new.html.haml
|
|
73
|
+
- lib/generators/templates/resource_controller/activerecord/app/views/%file_name%/show.html.haml
|
|
74
|
+
- lib/generators/templates/resource_controller/datamapper
|
|
75
|
+
- lib/generators/templates/resource_controller/datamapper/app
|
|
76
|
+
- lib/generators/templates/resource_controller/datamapper/app/views
|
|
77
|
+
- lib/generators/templates/resource_controller/datamapper/app/views/%file_name%
|
|
78
|
+
- lib/generators/templates/resource_controller/datamapper/app/views/%file_name%/edit.html.haml
|
|
79
|
+
- lib/generators/templates/resource_controller/datamapper/app/views/%file_name%/index.html.haml
|
|
80
|
+
- lib/generators/templates/resource_controller/datamapper/app/views/%file_name%/new.html.haml
|
|
81
|
+
- lib/generators/templates/resource_controller/datamapper/app/views/%file_name%/show.html.haml
|
|
82
|
+
- lib/generators/templates/resource_controller/none
|
|
83
|
+
- lib/generators/templates/resource_controller/none/app
|
|
84
|
+
- lib/generators/templates/resource_controller/none/app/views
|
|
85
|
+
- lib/generators/templates/resource_controller/none/app/views/%file_name%
|
|
86
|
+
- lib/generators/templates/resource_controller/none/app/views/%file_name%/edit.html.haml
|
|
87
|
+
- lib/generators/templates/resource_controller/none/app/views/%file_name%/index.html.haml
|
|
88
|
+
- lib/generators/templates/resource_controller/none/app/views/%file_name%/new.html.haml
|
|
89
|
+
- lib/generators/templates/resource_controller/none/app/views/%file_name%/show.html.haml
|
|
90
|
+
- lib/generators/templates/resource_controller/sequel
|
|
91
|
+
- lib/generators/templates/resource_controller/sequel/app
|
|
92
|
+
- lib/generators/templates/resource_controller/sequel/app/views
|
|
93
|
+
- lib/generators/templates/resource_controller/sequel/app/views/%file_name%
|
|
94
|
+
- lib/generators/templates/resource_controller/sequel/app/views/%file_name%/edit.html.haml
|
|
95
|
+
- lib/generators/templates/resource_controller/sequel/app/views/%file_name%/index.html.haml
|
|
96
|
+
- lib/generators/templates/resource_controller/sequel/app/views/%file_name%/new.html.haml
|
|
97
|
+
- lib/generators/templates/resource_controller/sequel/app/views/%file_name%/show.html.haml
|
|
48
98
|
- lib/merb-haml
|
|
49
99
|
- lib/merb-haml/merbtasks.rb
|
|
50
100
|
- lib/merb-haml/template.rb
|
|
@@ -69,7 +119,7 @@ files:
|
|
|
69
119
|
- spec/haml_spec.rb
|
|
70
120
|
- spec/spec_helper.rb
|
|
71
121
|
has_rdoc: true
|
|
72
|
-
homepage: http://
|
|
122
|
+
homepage: http://merbivore.com
|
|
73
123
|
post_install_message:
|
|
74
124
|
rdoc_options: []
|
|
75
125
|
|
|
@@ -89,8 +139,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
89
139
|
version:
|
|
90
140
|
requirements: []
|
|
91
141
|
|
|
92
|
-
rubyforge_project:
|
|
93
|
-
rubygems_version: 1.0
|
|
142
|
+
rubyforge_project: merb
|
|
143
|
+
rubygems_version: 1.2.0
|
|
94
144
|
signing_key:
|
|
95
145
|
specification_version: 2
|
|
96
146
|
summary: Merb plugin that provides HAML support
|