merb-haml 0.9.2
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/LICENSE +20 -0
- data/README +4 -0
- data/Rakefile +44 -0
- data/TODO +5 -0
- data/lib/merb-haml/merbtasks.rb +11 -0
- data/lib/merb-haml/template.rb +56 -0
- data/lib/merb-haml.rb +20 -0
- metadata +70 -0
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2008 YOUR NAME
|
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.
|
data/README
ADDED
data/Rakefile
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rake/gempackagetask'
|
3
|
+
|
4
|
+
PLUGIN = "merb-haml"
|
5
|
+
NAME = "merb-haml"
|
6
|
+
VERSION = "0.9.2"
|
7
|
+
AUTHOR = "Yehuda Katz"
|
8
|
+
EMAIL = "ykatz@engineyard.com"
|
9
|
+
HOMEPAGE = "http://merb-plugins.rubyforge.org/merb-haml/"
|
10
|
+
SUMMARY = "Merb plugin that provides HAML support"
|
11
|
+
|
12
|
+
spec = Gem::Specification.new do |s|
|
13
|
+
s.name = NAME
|
14
|
+
s.version = VERSION
|
15
|
+
s.platform = Gem::Platform::RUBY
|
16
|
+
s.has_rdoc = true
|
17
|
+
s.extra_rdoc_files = ["README", "LICENSE", 'TODO']
|
18
|
+
s.summary = SUMMARY
|
19
|
+
s.description = s.summary
|
20
|
+
s.author = AUTHOR
|
21
|
+
s.email = EMAIL
|
22
|
+
s.homepage = HOMEPAGE
|
23
|
+
s.add_dependency('merb-core', '>= 0.9.2')
|
24
|
+
s.require_path = 'lib'
|
25
|
+
s.autorequire = PLUGIN
|
26
|
+
s.files = %w(LICENSE README Rakefile TODO) + Dir.glob("{lib,specs}/**/*")
|
27
|
+
end
|
28
|
+
|
29
|
+
Rake::GemPackageTask.new(spec) do |pkg|
|
30
|
+
pkg.gem_spec = spec
|
31
|
+
end
|
32
|
+
|
33
|
+
task :install => [:package] do
|
34
|
+
sh %{sudo gem install pkg/#{NAME}-#{VERSION} --no-update-sources}
|
35
|
+
end
|
36
|
+
|
37
|
+
namespace :jruby do
|
38
|
+
|
39
|
+
desc "Run :package and install the resulting .gem with jruby"
|
40
|
+
task :install => :package do
|
41
|
+
sh %{#{SUDO} jruby -S gem install pkg/#{NAME}-#{Merb::VERSION}.gem --no-rdoc --no-ri}
|
42
|
+
end
|
43
|
+
|
44
|
+
end
|
data/TODO
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
namespace :haml do
|
2
|
+
desc "Compiles all sass files into CSS"
|
3
|
+
task :compile_sass do
|
4
|
+
gem 'haml'
|
5
|
+
require 'sass'
|
6
|
+
puts "*** Updating stylesheets"
|
7
|
+
Sass::Plugin.options = Merb::Config[:sass] if Merb::Config[:sass]
|
8
|
+
Sass::Plugin.update_stylesheets
|
9
|
+
puts "*** Done"
|
10
|
+
end
|
11
|
+
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
module Merb::Template
|
2
|
+
|
3
|
+
class Haml
|
4
|
+
|
5
|
+
# Defines a method for calling a specific HAML template.
|
6
|
+
#
|
7
|
+
# ==== Parameters
|
8
|
+
# path<String>:: Path to the template file.
|
9
|
+
# name<~to_s>:: The name of the template method.
|
10
|
+
# mod<Class, Module>::
|
11
|
+
# The class or module wherein this method should be defined.
|
12
|
+
def self.compile_template(path, name, mod)
|
13
|
+
path = File.expand_path(path)
|
14
|
+
config = (Merb::Config[:haml] || {}).inject({}) do |c, (k, v)|
|
15
|
+
c[k.to_sym] = v
|
16
|
+
c
|
17
|
+
end.merge :filename => path
|
18
|
+
template = ::Haml::Engine.new(File.read(path), config)
|
19
|
+
template.def_method(mod, name)
|
20
|
+
name
|
21
|
+
end
|
22
|
+
|
23
|
+
module Mixin
|
24
|
+
# ==== Parameters
|
25
|
+
# string<String>:: The string to add to the HAML buffer.
|
26
|
+
# binding<Binding>::
|
27
|
+
# Not used by HAML, but is necessary to conform to the concat_*
|
28
|
+
# interface.
|
29
|
+
def concat_haml(string, binding)
|
30
|
+
haml_buffer.buffer << string
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
34
|
+
Merb::Template.register_extensions(self, %w[haml])
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
module Haml
|
39
|
+
class Engine
|
40
|
+
|
41
|
+
# ==== Parameters
|
42
|
+
# object<Class, Module>::
|
43
|
+
# The class or module wherein this method should be defined.
|
44
|
+
# name<~to_s>:: The name of the template method.
|
45
|
+
# *local_names:: Local names to define in the HAML template.
|
46
|
+
def def_method(object, name, *local_names)
|
47
|
+
method = object.is_a?(Module) ? :module_eval : :instance_eval
|
48
|
+
|
49
|
+
setup = "@_engine = 'haml'"
|
50
|
+
|
51
|
+
object.send(method, "def #{name}(_haml_locals = {}); #{setup}; #{precompiled_with_ambles(local_names)}; end",
|
52
|
+
@options[:filename], 0)
|
53
|
+
end
|
54
|
+
|
55
|
+
end
|
56
|
+
end
|
data/lib/merb-haml.rb
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
# make sure we're running inside Merb
|
2
|
+
if defined?(Merb::Plugins)
|
3
|
+
require "haml"
|
4
|
+
require "merb-haml/template"
|
5
|
+
Merb::Plugins.add_rakefiles(File.join(File.dirname(__FILE__) / "merb-haml" / "merbtasks"))
|
6
|
+
|
7
|
+
Merb::BootLoader.after_app_loads do
|
8
|
+
if File.directory?(Merb.dir_for(:stylesheet) / "sass")
|
9
|
+
require "sass/plugin"
|
10
|
+
Sass::Plugin.options = Merb::Config[:sass] if Merb::Config[:sass]
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
# Hack because Haml uses symbolize_keys
|
15
|
+
class Hash
|
16
|
+
def symbolize_keys!
|
17
|
+
self
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
metadata
ADDED
@@ -0,0 +1,70 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: merb-haml
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.9.2
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Yehuda Katz
|
8
|
+
autorequire: merb-haml
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2008-03-24 00:00:00 -05:00
|
13
|
+
default_executable:
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: merb-core
|
17
|
+
version_requirement:
|
18
|
+
version_requirements: !ruby/object:Gem::Requirement
|
19
|
+
requirements:
|
20
|
+
- - ">="
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: 0.9.2
|
23
|
+
version:
|
24
|
+
description: Merb plugin that provides HAML support
|
25
|
+
email: ykatz@engineyard.com
|
26
|
+
executables: []
|
27
|
+
|
28
|
+
extensions: []
|
29
|
+
|
30
|
+
extra_rdoc_files:
|
31
|
+
- README
|
32
|
+
- LICENSE
|
33
|
+
- TODO
|
34
|
+
files:
|
35
|
+
- LICENSE
|
36
|
+
- README
|
37
|
+
- Rakefile
|
38
|
+
- TODO
|
39
|
+
- lib/merb-haml
|
40
|
+
- lib/merb-haml/merbtasks.rb
|
41
|
+
- lib/merb-haml/template.rb
|
42
|
+
- lib/merb-haml.rb
|
43
|
+
has_rdoc: true
|
44
|
+
homepage: http://merb-plugins.rubyforge.org/merb-haml/
|
45
|
+
post_install_message:
|
46
|
+
rdoc_options: []
|
47
|
+
|
48
|
+
require_paths:
|
49
|
+
- lib
|
50
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: "0"
|
55
|
+
version:
|
56
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
57
|
+
requirements:
|
58
|
+
- - ">="
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: "0"
|
61
|
+
version:
|
62
|
+
requirements: []
|
63
|
+
|
64
|
+
rubyforge_project:
|
65
|
+
rubygems_version: 1.0.1
|
66
|
+
signing_key:
|
67
|
+
specification_version: 2
|
68
|
+
summary: Merb plugin that provides HAML support
|
69
|
+
test_files: []
|
70
|
+
|